Struct litrs::ByteStringLit
source · 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 suffix(&self) -> &str
pub fn suffix(&self) -> &str
The optional suffix. Returns ""
if the suffix is empty/does not exist.
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
).
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 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>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
impl<B: Buffer> From<ByteStringLit<B>> for Literal
source§fn from(l: ByteStringLit<B>) -> Self
fn from(l: ByteStringLit<B>) -> Self
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
source§impl<B: PartialEq + Buffer> PartialEq for ByteStringLit<B>
impl<B: PartialEq + Buffer> PartialEq for ByteStringLit<B>
source§fn eq(&self, other: &ByteStringLit<B>) -> bool
fn eq(&self, other: &ByteStringLit<B>) -> bool
self
and other
values to be equal, and is used
by ==
.