@@ -60,7 +60,7 @@ fn builtin_any(iterable: PyIterable<IntoPyBool>, vm: &VirtualMachine) -> PyResul
60
60
61
61
fn builtin_ascii ( obj : PyObjectRef , vm : & VirtualMachine ) -> PyResult < String > {
62
62
let repr = vm. to_repr ( & obj) ?;
63
- let ascii = to_ascii ( & repr. value ) ;
63
+ let ascii = to_ascii ( repr. as_str ( ) ) ;
64
64
Ok ( ascii)
65
65
}
66
66
@@ -126,9 +126,9 @@ struct CompileArgs {
126
126
#[ cfg( feature = "rustpython-compiler" ) ]
127
127
fn builtin_compile ( args : CompileArgs , vm : & VirtualMachine ) -> PyResult < PyCodeRef > {
128
128
// 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 ( ) ,
132
132
} ;
133
133
134
134
let mode = args
@@ -137,7 +137,7 @@ fn builtin_compile(args: CompileArgs, vm: &VirtualMachine) -> PyResult<PyCodeRef
137
137
. parse :: < compile:: Mode > ( )
138
138
. map_err ( |err| vm. new_value_error ( err. to_string ( ) ) ) ?;
139
139
140
- vm. compile ( & source, mode, args. filename . value . to_string ( ) )
140
+ vm. compile ( source, mode, args. filename . as_str ( ) . to_string ( ) )
141
141
. map_err ( |err| vm. new_syntax_error ( & err) )
142
142
}
143
143
@@ -250,12 +250,9 @@ fn builtin_format(
250
250
format_spec : OptionalArg < PyStringRef > ,
251
251
vm : & VirtualMachine ,
252
252
) -> 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) ) ;
259
256
260
257
vm. call_method ( & value, "__format__" , vec ! [ format_spec. into_object( ) ] ) ?
261
258
. downcast ( )
@@ -598,8 +595,8 @@ impl Printer for &'_ PyObjectRef {
598
595
599
596
impl Printer for std:: io:: StdoutLock < ' _ > {
600
597
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 ( ) ;
603
600
Ok ( ( ) )
604
601
}
605
602
@@ -631,7 +628,7 @@ pub fn builtin_print(objects: Args, options: PrintOptions, vm: &VirtualMachine)
631
628
let sep = options
632
629
. sep
633
630
. as_ref ( )
634
- . map_or ( " " , |sep| & sep. value )
631
+ . map_or ( " " , |sep| sep. as_str ( ) )
635
632
. into_pyobject ( vm)
636
633
. unwrap ( ) ;
637
634
@@ -649,7 +646,7 @@ pub fn builtin_print(objects: Args, options: PrintOptions, vm: &VirtualMachine)
649
646
let end = options
650
647
. end
651
648
. as_ref ( )
652
- . map_or ( "\n " , |end| & end. value )
649
+ . map_or ( "\n " , |end| end. as_str ( ) )
653
650
. into_pyobject ( vm)
654
651
. unwrap ( ) ;
655
652
printer. write ( vm, end) ?;
@@ -902,7 +899,7 @@ pub fn builtin_build_class_(
902
899
mut kwargs : KwArgs ,
903
900
vm : & VirtualMachine ,
904
901
) -> PyResult {
905
- let name = qualified_name. value . split ( '.' ) . next_back ( ) . unwrap ( ) ;
902
+ let name = qualified_name. as_str ( ) . split ( '.' ) . next_back ( ) . unwrap ( ) ;
906
903
let name_obj = vm. new_str ( name. to_string ( ) ) ;
907
904
908
905
let mut metaclass = if let Some ( metaclass) = kwargs. pop_kwarg ( "metaclass" ) {
0 commit comments