File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -604,9 +604,15 @@ use crate::string;
604
604
#[ cfg( not( no_global_oom_handling) ) ]
605
605
#[ must_use]
606
606
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
607
+ #[ inline]
607
608
pub fn format ( args : Arguments < ' _ > ) -> string:: String {
608
- let capacity = args. estimated_capacity ( ) ;
609
- let mut output = string:: String :: with_capacity ( capacity) ;
610
- output. write_fmt ( args) . expect ( "a formatting trait implementation returned an error" ) ;
611
- output
609
+ #[ cold]
610
+ fn format_cold ( args : Arguments < ' _ > ) -> string:: String {
611
+ let capacity = args. estimated_capacity ( ) ;
612
+ let mut output = string:: String :: with_capacity ( capacity) ;
613
+ output. write_fmt ( args) . expect ( "a formatting trait implementation returned an error" ) ;
614
+ output
615
+ }
616
+
617
+ args. as_str ( ) . map_or_else ( || format_cold ( args) , crate :: borrow:: ToOwned :: to_owned)
612
618
}
You can’t perform that action at this time.
0 commit comments