File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,7 +190,10 @@ pub trait Write {
190190 /// ```
191191 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
192192 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+ }
194197 }
195198}
196199
Original file line number Diff line number Diff line change @@ -1506,15 +1506,19 @@ pub trait Write {
15061506 }
15071507 }
15081508
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+ }
15181522 }
15191523 }
15201524 }
Original file line number Diff line number Diff line change 265265#![ feature( exhaustive_patterns) ]
266266#![ feature( extend_one) ]
267267#![ feature( external_doc) ]
268+ #![ feature( fmt_as_str) ]
268269#![ feature( fn_traits) ]
269270#![ feature( format_args_nl) ]
270271#![ feature( future_readiness_fns) ]
You can’t perform that action at this time.
0 commit comments