File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use crate::mem;
10
10
use crate :: num:: fmt as numfmt;
11
11
use crate :: ops:: Deref ;
12
12
use crate :: result;
13
+ use crate :: slice;
13
14
use crate :: str;
14
15
15
16
mod builders;
@@ -422,6 +423,14 @@ impl Display for Arguments<'_> {
422
423
}
423
424
}
424
425
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
+
425
434
/// `?` formatting.
426
435
///
427
436
/// `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() {
11
11
assert_eq ! ( format!( "{: >3}" , 'a' ) , " a" ) ;
12
12
}
13
13
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
+
14
21
#[ test]
15
22
fn test_pointer_formats_data_pointer ( ) {
16
23
let b: & [ u8 ] = b"" ;
You can’t perform that action at this time.
0 commit comments