File tree 1 file changed +8
-0
lines changed
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ mod diagnostic;
45
45
#[ unstable( feature = "proc_macro_diagnostic" , issue = "54140" ) ]
46
46
pub use diagnostic:: { Diagnostic , Level , MultiSpan } ;
47
47
48
+ use std:: ffi:: CStr ;
48
49
use std:: ops:: { Range , RangeBounds } ;
49
50
use std:: path:: PathBuf ;
50
51
use std:: str:: FromStr ;
@@ -1351,6 +1352,13 @@ impl Literal {
1351
1352
Literal :: new ( bridge:: LitKind :: ByteStr , & string, None )
1352
1353
}
1353
1354
1355
+ /// C string literal.
1356
+ #[ unstable( feature = "proc_macro_c_str_literals" , issue = "119750" ) ]
1357
+ pub fn c_string ( string : & CStr ) -> Literal {
1358
+ let string = string. to_bytes ( ) . escape_ascii ( ) . to_string ( ) ;
1359
+ Literal :: new ( bridge:: LitKind :: CStr , & string, None )
1360
+ }
1361
+
1354
1362
/// Returns the span encompassing this literal.
1355
1363
#[ stable( feature = "proc_macro_lib2" , since = "1.29.0" ) ]
1356
1364
pub fn span ( & self ) -> Span {
You can’t perform that action at this time.
0 commit comments