File tree 3 files changed +18
-10
lines changed
3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,10 @@ pub trait Write {
190
190
/// ```
191
191
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
192
192
fn write_fmt ( mut self : & mut Self , args : Arguments < ' _ > ) -> Result {
193
- write ( & mut self , args)
193
+ match args. as_str ( ) {
194
+ Some ( s) => self . write_str ( s) ,
195
+ None => write ( & mut self , args) ,
196
+ }
194
197
}
195
198
}
196
199
Original file line number Diff line number Diff line change @@ -1506,15 +1506,19 @@ pub trait Write {
1506
1506
}
1507
1507
}
1508
1508
1509
- let mut output = Adaptor { inner : self , error : Ok ( ( ) ) } ;
1510
- match fmt:: write ( & mut output, fmt) {
1511
- Ok ( ( ) ) => Ok ( ( ) ) ,
1512
- Err ( ..) => {
1513
- // check if the error came from the underlying `Write` or not
1514
- if output. error . is_err ( ) {
1515
- output. error
1516
- } else {
1517
- Err ( Error :: new ( ErrorKind :: Other , "formatter error" ) )
1509
+ if let Some ( s) = fmt. as_str ( ) {
1510
+ self . write_all ( s. as_bytes ( ) )
1511
+ } else {
1512
+ let mut output = Adaptor { inner : self , error : Ok ( ( ) ) } ;
1513
+ match fmt:: write ( & mut output, fmt) {
1514
+ Ok ( ( ) ) => Ok ( ( ) ) ,
1515
+ Err ( ..) => {
1516
+ // check if the error came from the underlying `Write` or not
1517
+ if output. error . is_err ( ) {
1518
+ output. error
1519
+ } else {
1520
+ Err ( Error :: new ( ErrorKind :: Other , "formatter error" ) )
1521
+ }
1518
1522
}
1519
1523
}
1520
1524
}
Original file line number Diff line number Diff line change 265
265
#![ feature( exhaustive_patterns) ]
266
266
#![ feature( extend_one) ]
267
267
#![ feature( external_doc) ]
268
+ #![ feature( fmt_as_str) ]
268
269
#![ feature( fn_traits) ]
269
270
#![ feature( format_args_nl) ]
270
271
#![ feature( future_readiness_fns) ]
You can’t perform that action at this time.
0 commit comments