pub struct CStringLit<B: Buffer> { /* private fields */ }Expand description
A C string or raw C string literal, e.g. c"hello" or cr#"abc"def"#.
See the reference for more information.
Implementations§
Source§impl<B: Buffer> CStringLit<B>
impl<B: Buffer> CStringLit<B>
Sourcepub fn parse(input: B) -> Result<Self, ParseError>
pub fn parse(input: B) -> Result<Self, ParseError>
Parses the input as a (raw) byte string literal. Returns an error if the input is invalid or represents a different kind of literal.
Sourcepub fn value(&self) -> &CStr
pub fn value(&self) -> &CStr
Returns the string value this literal represents (where all escapes have been turned into their respective values).
Sourcepub fn into_value(self) -> CString
pub fn into_value(self) -> CString
Like value but returns an owned version of the value.
Sourcepub fn suffix(&self) -> &str
pub fn suffix(&self) -> &str
The optional suffix. Returns "" if the suffix is empty/does not exist.
Sourcepub fn is_raw_c_string(&self) -> bool
pub fn is_raw_c_string(&self) -> bool
Returns whether this literal is a raw string literal (starting with
cr).
Sourcepub fn into_raw_input(self) -> B
pub fn into_raw_input(self) -> B
Returns the raw input that was passed to parse, potentially owned.
Source§impl CStringLit<&str>
impl CStringLit<&str>
Sourcepub fn into_owned(self) -> CStringLit<String>
pub fn into_owned(self) -> CStringLit<String>
Makes a copy of the underlying buffer and returns the owned version of
Self.
Trait Implementations§
Source§impl<B: Clone + Buffer> Clone for CStringLit<B>
impl<B: Clone + Buffer> Clone for CStringLit<B>
Source§fn clone(&self) -> CStringLit<B>
fn clone(&self) -> CStringLit<B>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<B: Buffer> Display for CStringLit<B>
impl<B: Buffer> Display for CStringLit<B>
Source§impl<B: Buffer> From<CStringLit<B>> for Literal
impl<B: Buffer> From<CStringLit<B>> for Literal
Source§fn from(l: CStringLit<B>) -> Self
fn from(l: CStringLit<B>) -> Self
Converts to this type from the input type.
Source§impl<B: Buffer> From<CStringLit<B>> for Literal<B>
impl<B: Buffer> From<CStringLit<B>> for Literal<B>
Source§fn from(src: CStringLit<B>) -> Self
fn from(src: CStringLit<B>) -> Self
Converts to this type from the input type.
impl<B: Eq + Buffer> Eq for CStringLit<B>
impl<B: Buffer> StructuralPartialEq for CStringLit<B>
Auto Trait Implementations§
impl<B> Freeze for CStringLit<B>where
B: Freeze,
impl<B> RefUnwindSafe for CStringLit<B>where
B: RefUnwindSafe,
impl<B> Send for CStringLit<B>where
B: Send,
impl<B> Sync for CStringLit<B>where
B: Sync,
impl<B> Unpin for CStringLit<B>where
B: Unpin,
impl<B> UnwindSafe for CStringLit<B>where
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more