@@ -60,7 +60,7 @@ fn builtin_any(iterable: PyIterable<IntoPyBool>, vm: &VirtualMachine) -> PyResul
6060
6161fn builtin_ascii ( obj : PyObjectRef , vm : & VirtualMachine ) -> PyResult < String > {
6262 let repr = vm. to_repr ( & obj) ?;
63- let ascii = to_ascii ( & repr. value ) ;
63+ let ascii = to_ascii ( repr. as_str ( ) ) ;
6464 Ok ( ascii)
6565}
6666
@@ -126,9 +126,9 @@ struct CompileArgs {
126126#[ cfg( feature = "rustpython-compiler" ) ]
127127fn builtin_compile ( args : CompileArgs , vm : & VirtualMachine ) -> PyResult < PyCodeRef > {
128128 // TODO: compile::compile should probably get bytes
129- let source = match args. source {
130- Either :: A ( string) => string. value . to_string ( ) ,
131- Either :: B ( bytes) => str:: from_utf8 ( & bytes) . unwrap ( ) . to_string ( ) ,
129+ let source = match & args. source {
130+ Either :: A ( string) => string. as_str ( ) ,
131+ Either :: B ( bytes) => str:: from_utf8 ( bytes) . unwrap ( ) ,
132132 } ;
133133
134134 let mode = args
@@ -137,7 +137,7 @@ fn builtin_compile(args: CompileArgs, vm: &VirtualMachine) -> PyResult<PyCodeRef
137137 . parse :: < compile:: Mode > ( )
138138 . map_err ( |err| vm. new_value_error ( err. to_string ( ) ) ) ?;
139139
140- vm. compile ( & source, mode, args. filename . value . to_string ( ) )
140+ vm. compile ( source, mode, args. filename . as_str ( ) . to_string ( ) )
141141 . map_err ( |err| vm. new_syntax_error ( & err) )
142142}
143143
@@ -250,12 +250,9 @@ fn builtin_format(
250250 format_spec : OptionalArg < PyStringRef > ,
251251 vm : & VirtualMachine ,
252252) -> PyResult < PyStringRef > {
253- let format_spec = format_spec. into_option ( ) . unwrap_or_else ( || {
254- PyString {
255- value : "" . to_string ( ) ,
256- }
257- . into_ref ( vm)
258- } ) ;
253+ let format_spec = format_spec
254+ . into_option ( )
255+ . unwrap_or_else ( || PyString :: from ( "" ) . into_ref ( vm) ) ;
259256
260257 vm. call_method ( & value, "__format__" , vec ! [ format_spec. into_object( ) ] ) ?
261258 . downcast ( )
@@ -598,8 +595,8 @@ impl Printer for &'_ PyObjectRef {
598595
599596impl Printer for std:: io:: StdoutLock < ' _ > {
600597 fn write ( & mut self , vm : & VirtualMachine , obj : PyObjectRef ) -> PyResult < ( ) > {
601- let s = & vm. to_str ( & obj) ?. value ;
602- write ! ( self , "{}" , s) . unwrap ( ) ;
598+ let s = vm. to_str ( & obj) ?;
599+ write ! ( self , "{}" , s. as_str ( ) ) . unwrap ( ) ;
603600 Ok ( ( ) )
604601 }
605602
@@ -631,7 +628,7 @@ pub fn builtin_print(objects: Args, options: PrintOptions, vm: &VirtualMachine)
631628 let sep = options
632629 . sep
633630 . as_ref ( )
634- . map_or ( " " , |sep| & sep. value )
631+ . map_or ( " " , |sep| sep. as_str ( ) )
635632 . into_pyobject ( vm)
636633 . unwrap ( ) ;
637634
@@ -649,7 +646,7 @@ pub fn builtin_print(objects: Args, options: PrintOptions, vm: &VirtualMachine)
649646 let end = options
650647 . end
651648 . as_ref ( )
652- . map_or ( "\n " , |end| & end. value )
649+ . map_or ( "\n " , |end| end. as_str ( ) )
653650 . into_pyobject ( vm)
654651 . unwrap ( ) ;
655652 printer. write ( vm, end) ?;
@@ -902,7 +899,7 @@ pub fn builtin_build_class_(
902899 mut kwargs : KwArgs ,
903900 vm : & VirtualMachine ,
904901) -> PyResult {
905- let name = qualified_name. value . split ( '.' ) . next_back ( ) . unwrap ( ) ;
902+ let name = qualified_name. as_str ( ) . split ( '.' ) . next_back ( ) . unwrap ( ) ;
906903 let name_obj = vm. new_str ( name. to_string ( ) ) ;
907904
908905 let mut metaclass = if let Some ( metaclass) = kwargs. pop_kwarg ( "metaclass" ) {
0 commit comments