pub struct Quoted<'lex> { /* private fields */ }
Expand description
A quoted literal.
Implementations§
source§impl<'lex> Quoted<'lex>
impl<'lex> Quoted<'lex>
sourcepub fn delimiters(self) -> (SpanId, SpanId)
pub fn delimiters(self) -> (SpanId, SpanId)
Returns this token’s quote delimiters.
sourcepub fn raw_content(self) -> impl Iterator<Item = Content> + 'lex
pub fn raw_content(self) -> impl Iterator<Item = Content> + 'lex
Returns the raw content of this token.
There are two kinds of content: either a literal span of Unicode scalars
(represented as a SpanId
pointing to those characters) or a single
escape, potentially with some side data.
It is up to the user of the library to decode these two content types into
strings. Quoted::to_utf8()
helps with the common case of doing this for
UTF-8 strings.
sourcepub fn unique_content(self) -> Option<Content>
pub fn unique_content(self) -> Option<Content>
Returns the unique single Content
of this token, if it is unique.
sourcepub fn to_utf8(
self,
decode_esc: impl FnMut(SpanId, Option<SpanId>, &mut String)
) -> String
pub fn to_utf8( self, decode_esc: impl FnMut(SpanId, Option<SpanId>, &mut String) ) -> String
Constructs a UTF-8 string in the “obvious way”, using this token and a mapping function for escapes.
sourcepub fn has_prefix(self, expected: &str) -> bool
pub fn has_prefix(self, expected: &str) -> bool
Checks whether this identifier has a particular prefix.
sourcepub fn has_suffix(self, expected: &str) -> bool
pub fn has_suffix(self, expected: &str) -> bool
Checks whether this identifier has a particular prefix.
Trait Implementations§
source§impl Spanned for Quoted<'_>
impl Spanned for Quoted<'_>
source§fn comments<'ctx>(&self, ctx: &'ctx Context) -> Comments<'ctx>
fn comments<'ctx>(&self, ctx: &'ctx Context) -> Comments<'ctx>
Forwards to
SpanId::comments()
.impl<'lex> Copy for Quoted<'lex>
Auto Trait Implementations§
impl<'lex> RefUnwindSafe for Quoted<'lex>
impl<'lex> Send for Quoted<'lex>
impl<'lex> Sync for Quoted<'lex>
impl<'lex> Unpin for Quoted<'lex>
impl<'lex> UnwindSafe for Quoted<'lex>
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