@@ -528,11 +528,13 @@ impl<'a> State<'a> {
528
528
self . head ( & visibility_qualified ( & item. vis , "extern crate" ) ) ?;
529
529
if let Some ( p) = * optional_path {
530
530
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
+ } ) ?;
536
538
self . s . space ( ) ?;
537
539
self . s . word ( "as" ) ?;
538
540
self . s . space ( ) ?;
@@ -623,7 +625,7 @@ impl<'a> State<'a> {
623
625
}
624
626
hir:: ItemGlobalAsm ( ref ga) => {
625
627
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 ) ) ?;
627
629
self . end ( ) ?
628
630
}
629
631
hir:: ItemTy ( ref ty, ref generics) => {
@@ -1469,20 +1471,21 @@ impl<'a> State<'a> {
1469
1471
hir:: ExprInlineAsm ( ref a, ref outputs, ref inputs) => {
1470
1472
self . s . word ( "asm!" ) ?;
1471
1473
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 ) ) ?;
1473
1475
self . word_space ( ":" ) ?;
1474
1476
1475
1477
let mut out_idx = 0 ;
1476
1478
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 )
1483
1487
}
1484
- _ => s. print_string ( & constraint, ast:: StrStyle :: Cooked ) ?,
1485
- }
1488
+ } ) ?;
1486
1489
s. popen ( ) ?;
1487
1490
s. print_expr ( & outputs[ out_idx] ) ?;
1488
1491
s. pclose ( ) ?;
@@ -1494,7 +1497,7 @@ impl<'a> State<'a> {
1494
1497
1495
1498
let mut in_idx = 0 ;
1496
1499
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 ) ) ?;
1498
1501
s. popen ( ) ?;
1499
1502
s. print_expr ( & inputs[ in_idx] ) ?;
1500
1503
s. pclose ( ) ?;
@@ -1505,7 +1508,7 @@ impl<'a> State<'a> {
1505
1508
self . word_space ( ":" ) ?;
1506
1509
1507
1510
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 ) ) ?;
1509
1512
Ok ( ( ) )
1510
1513
} ) ?;
1511
1514
@@ -1578,7 +1581,7 @@ impl<'a> State<'a> {
1578
1581
}
1579
1582
1580
1583
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 ) ) ?;
1582
1585
self . ann . post ( self , NodeName ( & name) )
1583
1586
}
1584
1587
@@ -1936,7 +1939,7 @@ impl<'a> State<'a> {
1936
1939
self . commasep ( Inconsistent , & decl. inputs , |s, ty| {
1937
1940
s. ibox ( indent_unit) ?;
1938
1941
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 ) ) ?;
1940
1943
s. s . word ( ":" ) ?;
1941
1944
s. s . space ( ) ?;
1942
1945
} else if let Some ( body_id) = body_id {
0 commit comments