File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ mod diagnostic;
4545#[ unstable( feature = "proc_macro_diagnostic" , issue = "54140" ) ]
4646pub use diagnostic:: { Diagnostic , Level , MultiSpan } ;
4747
48+ use std:: ffi:: CStr ;
4849use std:: ops:: { Range , RangeBounds } ;
4950use std:: path:: PathBuf ;
5051use std:: str:: FromStr ;
@@ -1351,6 +1352,13 @@ impl Literal {
13511352 Literal :: new ( bridge:: LitKind :: ByteStr , & string, None )
13521353 }
13531354
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+
13541362 /// Returns the span encompassing this literal.
13551363 #[ stable( feature = "proc_macro_lib2" , since = "1.29.0" ) ]
13561364 pub fn span ( & self ) -> Span {
You can’t perform that action at this time.
0 commit comments