File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use crate::mem;
1010use crate :: num:: fmt as numfmt;
1111use crate :: ops:: Deref ;
1212use crate :: result;
13+ use crate :: slice;
1314use crate :: str;
1415
1516mod builders;
@@ -422,6 +423,14 @@ impl Display for Arguments<'_> {
422423 }
423424}
424425
426+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
427+ impl < ' a > From < & ' a & ' static str > for Arguments < ' a > {
428+ #[ inline]
429+ fn from ( value : & ' a & ' static str ) -> Self {
430+ Self :: new_const ( slice:: from_ref ( value) )
431+ }
432+ }
433+
425434/// `?` formatting.
426435///
427436/// `Debug` should format the output in a programmer-facing, debugging context.
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ fn test_format_flags() {
1111 assert_eq ! ( format!( "{: >3}" , 'a' ) , " a" ) ;
1212}
1313
14+ #[ test]
15+ fn test_arguments_from_str ( ) {
16+ assert_eq ! ( core:: fmt:: Arguments :: from( & "a string literal" ) . to_string( ) , "a string literal" ) ;
17+
18+ assert_eq ! ( core:: fmt:: Arguments :: from( & "a string literal" ) . as_str( ) , Some ( "a string literal" ) ) ;
19+ }
20+
1421#[ test]
1522fn test_pointer_formats_data_pointer ( ) {
1623 let b: & [ u8 ] = b"" ;
You can’t perform that action at this time.
0 commit comments