@@ -528,11 +528,13 @@ impl<'a> State<'a> {
528528 self . head ( & visibility_qualified ( & item. vis , "extern crate" ) ) ?;
529529 if let Some ( p) = * optional_path {
530530 let val = p. as_str ( ) ;
531- if val. contains ( "-" ) {
532- self . print_string ( & val, ast:: StrStyle :: Cooked ) ?;
533- } else {
534- self . print_name ( p) ?;
535- }
531+ val. with ( |str| {
532+ if str. contains ( "-" ) {
533+ self . print_string ( str, ast:: StrStyle :: Cooked )
534+ } else {
535+ self . print_name ( p)
536+ }
537+ } ) ?;
536538 self . s . space ( ) ?;
537539 self . s . word ( "as" ) ?;
538540 self . s . space ( ) ?;
@@ -623,7 +625,7 @@ impl<'a> State<'a> {
623625 }
624626 hir:: ItemGlobalAsm ( ref ga) => {
625627 self . head ( & visibility_qualified ( & item. vis , "global asm" ) ) ?;
626- self . s . word ( & ga . asm . as_str ( ) ) ?;
628+ ga . asm . with_str ( |str| self . s . word ( str ) ) ?;
627629 self . end ( ) ?
628630 }
629631 hir:: ItemTy ( ref ty, ref generics) => {
@@ -1469,20 +1471,21 @@ impl<'a> State<'a> {
14691471 hir:: ExprInlineAsm ( ref a, ref outputs, ref inputs) => {
14701472 self . s . word ( "asm!" ) ?;
14711473 self . popen ( ) ?;
1472- self . print_string ( & a. asm . as_str ( ) , a. asm_str_style ) ?;
1474+ a. asm . with_str ( |str| self . print_string ( str , a. asm_str_style ) ) ?;
14731475 self . word_space ( ":" ) ?;
14741476
14751477 let mut out_idx = 0 ;
14761478 self . commasep ( Inconsistent , & a. outputs , |s, out| {
1477- let constraint = out. constraint . as_str ( ) ;
1478- let mut ch = constraint. chars ( ) ;
1479- match ch. next ( ) {
1480- Some ( '=' ) if out. is_rw => {
1481- s. print_string ( & format ! ( "+{}" , ch. as_str( ) ) ,
1482- ast:: StrStyle :: Cooked ) ?
1479+ out. constraint . with_str ( |constraint| {
1480+ let mut ch = constraint. chars ( ) ;
1481+ match ch. next ( ) {
1482+ Some ( '=' ) if out. is_rw => {
1483+ s. print_string ( & format ! ( "+{}" , ch. as_str( ) ) ,
1484+ ast:: StrStyle :: Cooked )
1485+ }
1486+ _ => s. print_string ( & constraint, ast:: StrStyle :: Cooked )
14831487 }
1484- _ => s. print_string ( & constraint, ast:: StrStyle :: Cooked ) ?,
1485- }
1488+ } ) ?;
14861489 s. popen ( ) ?;
14871490 s. print_expr ( & outputs[ out_idx] ) ?;
14881491 s. pclose ( ) ?;
@@ -1494,7 +1497,7 @@ impl<'a> State<'a> {
14941497
14951498 let mut in_idx = 0 ;
14961499 self . commasep ( Inconsistent , & a. inputs , |s, co| {
1497- s. print_string ( & co . as_str ( ) , ast:: StrStyle :: Cooked ) ?;
1500+ co . with_str ( |str| s. print_string ( str , ast:: StrStyle :: Cooked ) ) ?;
14981501 s. popen ( ) ?;
14991502 s. print_expr ( & inputs[ in_idx] ) ?;
15001503 s. pclose ( ) ?;
@@ -1505,7 +1508,7 @@ impl<'a> State<'a> {
15051508 self . word_space ( ":" ) ?;
15061509
15071510 self . commasep ( Inconsistent , & a. clobbers , |s, co| {
1508- s. print_string ( & co . as_str ( ) , ast:: StrStyle :: Cooked ) ?;
1511+ co . with_str ( |str| s. print_string ( str , ast:: StrStyle :: Cooked ) ) ?;
15091512 Ok ( ( ) )
15101513 } ) ?;
15111514
@@ -1578,7 +1581,7 @@ impl<'a> State<'a> {
15781581 }
15791582
15801583 pub fn print_name ( & mut self , name : ast:: Name ) -> io:: Result < ( ) > {
1581- self . s . word ( & name . as_str ( ) ) ?;
1584+ name . with_str ( |str| self . s . word ( str ) ) ?;
15821585 self . ann . post ( self , NodeName ( & name) )
15831586 }
15841587
@@ -1936,7 +1939,7 @@ impl<'a> State<'a> {
19361939 self . commasep ( Inconsistent , & decl. inputs , |s, ty| {
19371940 s. ibox ( indent_unit) ?;
19381941 if let Some ( name) = arg_names. get ( i) {
1939- s. s . word ( & name . node . as_str ( ) ) ?;
1942+ name . node . with_str ( |str| s. s . word ( str ) ) ?;
19401943 s. s . word ( ":" ) ?;
19411944 s. s . space ( ) ?;
19421945 } else if let Some ( body_id) = body_id {
0 commit comments