@@ -66,7 +66,7 @@ impl AsRef<str> for PyString {
6666
6767impl < T > From < & T > for PyString
6868where
69- T : AsRef < T > + ?Sized ,
69+ T : AsRef < str > + ?Sized ,
7070{
7171 fn from ( s : & T ) -> PyString {
7272 s. as_ref ( ) . to_owned ( ) . into ( )
@@ -745,10 +745,8 @@ impl PyString {
745745
746746 #[ pymethod]
747747 fn splitlines ( & self , args : pystr:: SplitLinesArgs , vm : & VirtualMachine ) -> PyObjectRef {
748- vm. ctx . new_list (
749- self . value
750- . py_splitlines ( args, |s| vm. ctx . new_str ( s. to_owned ( ) ) ) ,
751- )
748+ vm. ctx
749+ . new_list ( self . value . py_splitlines ( args, |s| vm. ctx . new_str ( s) ) )
752750 }
753751
754752 #[ pymethod]
@@ -1124,7 +1122,7 @@ impl IntoPyObject for String {
11241122
11251123impl IntoPyObject for & str {
11261124 fn into_pyobject ( self , vm : & VirtualMachine ) -> PyObjectRef {
1127- vm. ctx . new_str ( self . to_owned ( ) )
1125+ vm. ctx . new_str ( self )
11281126 }
11291127}
11301128
@@ -1308,13 +1306,9 @@ mod tests {
13081306 let vm: VirtualMachine = Default :: default ( ) ;
13091307
13101308 let table = vm. context ( ) . new_dict ( ) ;
1311- table
1312- . set_item ( "a" , vm. ctx . new_str ( "🎅" . to_owned ( ) ) , & vm)
1313- . unwrap ( ) ;
1309+ table. set_item ( "a" , vm. ctx . new_str ( "🎅" ) , & vm) . unwrap ( ) ;
13141310 table. set_item ( "b" , vm. get_none ( ) , & vm) . unwrap ( ) ;
1315- table
1316- . set_item ( "c" , vm. ctx . new_str ( "xda" . to_owned ( ) ) , & vm)
1317- . unwrap ( ) ;
1311+ table. set_item ( "c" , vm. ctx . new_str ( "xda" ) , & vm) . unwrap ( ) ;
13181312 let translated = PyString :: maketrans (
13191313 table. into_object ( ) ,
13201314 OptionalArg :: Missing ,
0 commit comments