@@ -214,7 +214,7 @@ impl PyString {
214214 #[ pymethod( name = "__add__" ) ]
215215 fn add ( & self , rhs : PyObjectRef , vm : & VirtualMachine ) -> PyResult < String > {
216216 if objtype:: isinstance ( & rhs, & vm. ctx . str_type ( ) ) {
217- Ok ( format ! ( "{}{}" , self . value, get_value ( & rhs) ) )
217+ Ok ( format ! ( "{}{}" , self . value, borrow_value ( & rhs) ) )
218218 } else {
219219 Err ( vm. new_type_error ( format ! ( "Cannot add {} and {}" , self , rhs) ) )
220220 }
@@ -228,7 +228,7 @@ impl PyString {
228228 #[ pymethod( name = "__eq__" ) ]
229229 fn eq ( & self , rhs : PyObjectRef , vm : & VirtualMachine ) -> PyObjectRef {
230230 if objtype:: isinstance ( & rhs, & vm. ctx . str_type ( ) ) {
231- vm. new_bool ( self . value == get_value ( & rhs) )
231+ vm. new_bool ( self . value == borrow_value ( & rhs) )
232232 } else {
233233 vm. ctx . not_implemented ( )
234234 }
@@ -237,7 +237,7 @@ impl PyString {
237237 #[ pymethod( name = "__ne__" ) ]
238238 fn ne ( & self , rhs : PyObjectRef , vm : & VirtualMachine ) -> PyObjectRef {
239239 if objtype:: isinstance ( & rhs, & vm. ctx . str_type ( ) ) {
240- vm. new_bool ( self . value != get_value ( & rhs) )
240+ vm. new_bool ( self . value != borrow_value ( & rhs) )
241241 } else {
242242 vm. ctx . not_implemented ( )
243243 }
@@ -623,8 +623,8 @@ impl PyString {
623623 actual_type
624624 ) ) ) ;
625625 }
626- let format_string_text = get_value ( zelf) ;
627- match FormatString :: from_str ( format_string_text. as_str ( ) ) {
626+ let format_string_text = borrow_value ( zelf) ;
627+ match FormatString :: from_str ( format_string_text) {
628628 Ok ( format_string) => perform_format ( vm, & format_string, & args) ,
629629 Err ( err) => match err {
630630 FormatParseError :: UnmatchedBracket => {
@@ -649,8 +649,8 @@ impl PyString {
649649 }
650650
651651 let zelf = & args. args [ 0 ] ;
652- let format_string_text = get_value ( zelf) ;
653- match FormatString :: from_str ( format_string_text. as_str ( ) ) {
652+ let format_string_text = borrow_value ( zelf) ;
653+ match FormatString :: from_str ( format_string_text) {
654654 Ok ( format_string) => perform_format_map ( vm, & format_string, & args. args [ 1 ] ) ,
655655 Err ( err) => match err {
656656 FormatParseError :: UnmatchedBracket => {
@@ -1288,7 +1288,7 @@ pub fn init(ctx: &PyContext) {
12881288 PyStringReverseIterator :: extend_class ( ctx, & ctx. types . strreverseiterator_type ) ;
12891289}
12901290
1291- pub fn get_value ( obj : & PyObjectRef ) -> String {
1291+ pub fn clone_value ( obj : & PyObjectRef ) -> String {
12921292 obj. payload :: < PyString > ( ) . unwrap ( ) . value . clone ( )
12931293}
12941294
@@ -1341,7 +1341,7 @@ fn do_cformat_specifier(
13411341 CFormatPreconversor :: Ascii => vm. call_method ( & obj. clone ( ) , "__repr__" , vec ! [ ] ) ?,
13421342 CFormatPreconversor :: Bytes => vm. call_method ( & obj. clone ( ) , "decode" , vec ! [ ] ) ?,
13431343 } ;
1344- Ok ( format_spec. format_string ( get_value ( & result) ) )
1344+ Ok ( format_spec. format_string ( clone_value ( & result) ) )
13451345 }
13461346 CFormatType :: Number ( _) => {
13471347 if !objtype:: isinstance ( & obj, & vm. ctx . int_type ( ) ) {
@@ -1384,7 +1384,7 @@ fn do_cformat_specifier(
13841384 }
13851385 }
13861386 } else if objtype:: isinstance ( & obj, & vm. ctx . str_type ( ) ) {
1387- let s: String = get_value ( & obj) ;
1387+ let s = borrow_value ( & obj) ;
13881388 let num_chars = s. chars ( ) . count ( ) ;
13891389 if num_chars != 1 {
13901390 Err ( vm. new_type_error ( "%c requires int or char" . to_string ( ) ) )
@@ -1573,7 +1573,7 @@ fn perform_format(
15731573 }
15741574 } ;
15751575 auto_argument_index += 1 ;
1576- get_value ( & result)
1576+ clone_value ( & result)
15771577 }
15781578 FormatPart :: IndexSpec ( index, format_spec) => {
15791579 let result = match arguments. args . get ( * index + 1 ) {
@@ -1582,7 +1582,7 @@ fn perform_format(
15821582 return Err ( vm. new_index_error ( "tuple index out of range" . to_string ( ) ) ) ;
15831583 }
15841584 } ;
1585- get_value ( & result)
1585+ clone_value ( & result)
15861586 }
15871587 FormatPart :: KeywordSpec ( keyword, format_spec) => {
15881588 let result = match arguments. get_optional_kwarg ( & keyword) {
@@ -1591,7 +1591,7 @@ fn perform_format(
15911591 return Err ( vm. new_key_error ( vm. new_str ( keyword. to_string ( ) ) ) ) ;
15921592 }
15931593 } ;
1594- get_value ( & result)
1594+ clone_value ( & result)
15951595 }
15961596 FormatPart :: Literal ( literal) => literal. clone ( ) ,
15971597 } ;
@@ -1616,7 +1616,7 @@ fn perform_format_map(
16161616 FormatPart :: KeywordSpec ( keyword, format_spec) => {
16171617 let argument = dict. get_item ( keyword, & vm) ?;
16181618 let result = call_object_format ( vm, argument. clone ( ) , & format_spec) ?;
1619- get_value ( & result)
1619+ clone_value ( & result)
16201620 }
16211621 FormatPart :: Literal ( literal) => literal. clone ( ) ,
16221622 } ;
0 commit comments