pub struct ByteStringLit<B: Buffer> { /* private fields */ }
Expand description
A byte string or raw byte string literal, e.g. b"hello"
or br#"abc"def"#
.
See the reference for more information.
Implementations§
Source§impl<B: Buffer> ByteStringLit<B>
impl<B: Buffer> ByteStringLit<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) -> &[u8] ⓘ
pub fn value(&self) -> &[u8] ⓘ
Returns the string value this literal represents (where all escapes have been turned into their respective values).
Sourcepub fn into_value(self) -> B::ByteCow
pub fn into_value(self) -> B::ByteCow
Like value
but returns a potentially owned version of the value.
The return value is either Cow<'static, [u8]>
if B = String
, or
Cow<'a, [u8]>
if B = &'a str
.
Sourcepub fn is_raw_byte_string(&self) -> bool
pub fn is_raw_byte_string(&self) -> bool
Returns whether this literal is a raw string literal (starting with
r
).
Source§impl ByteStringLit<&str>
impl ByteStringLit<&str>
Sourcepub fn into_owned(self) -> ByteStringLit<String>
pub fn into_owned(self) -> ByteStringLit<String>
Makes a copy of the underlying buffer and returns the owned version of
Self
.
Trait Implementations§
Source§impl<B: Clone + Buffer> Clone for ByteStringLit<B>
impl<B: Clone + Buffer> Clone for ByteStringLit<B>
Source§fn clone(&self) -> ByteStringLit<B>
fn clone(&self) -> ByteStringLit<B>
Returns a copy 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 ByteStringLit<B>
impl<B: Buffer> Display for ByteStringLit<B>
Source§impl<B: Buffer> From<ByteStringLit<B>> for Literal<B>
impl<B: Buffer> From<ByteStringLit<B>> for Literal<B>
Source§fn from(src: ByteStringLit<B>) -> Self
fn from(src: ByteStringLit<B>) -> Self
Converts to this type from the input type.
impl<B: Eq + Buffer> Eq for ByteStringLit<B>
impl<B: Buffer> StructuralPartialEq for ByteStringLit<B>
Auto Trait Implementations§
impl<B> Freeze for ByteStringLit<B>where
B: Freeze,
impl<B> RefUnwindSafe for ByteStringLit<B>where
B: RefUnwindSafe,
impl<B> Send for ByteStringLit<B>where
B: Send,
impl<B> Sync for ByteStringLit<B>where
B: Sync,
impl<B> Unpin for ByteStringLit<B>where
B: Unpin,
impl<B> UnwindSafe for ByteStringLit<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