pub struct TrimmedLiteral { /* private fields */ }
Expand description
A literal with meta info where the first and list whitespace may be found.
Implementations§
Source§impl TrimmedLiteral
impl TrimmedLiteral
Sourcepub fn from(
variant: CommentVariant,
content: &str,
pre: usize,
post: usize,
line: usize,
column: usize,
) -> Result<TrimmedLiteral, String>
pub fn from( variant: CommentVariant, content: &str, pre: usize, post: usize, line: usize, column: usize, ) -> Result<TrimmedLiteral, String>
Creates a new (single line) literal from the variant, the content, the size of the pre & post and the line/column on which it starts. Fails if provided with multiline content (i.e. if the content contains a line-break).
Source§impl TrimmedLiteral
impl TrimmedLiteral
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Represent the rendered content as str
.
Does not contain pre
and post
characters.
Sourcepub fn as_untrimmed_str(&self) -> &str
pub fn as_untrimmed_str(&self) -> &str
Full representation including prefix
and postfix
characters.
Sourcepub fn len_in_chars(&self) -> usize
pub fn len_in_chars(&self) -> usize
Length in characters, excluding pre
and post
.
Sourcepub fn pre(&self) -> usize
pub fn pre(&self) -> usize
Obtain the number of characters in pre()
.
Since all pre characters are ASCII, this is equivalent to the number of
bytes in pre()
.
Sourcepub fn post(&self) -> usize
pub fn post(&self) -> usize
Obtain the number of characters in post()
.
Since all pre characters are ASCII, this is equivalent to the number of
bytes in post()
.
Sourcepub fn span(&self) -> Span
pub fn span(&self) -> Span
The span that is covered by this literal.
Covers only the content, no marker or helper characters.
Sourcepub fn variant(&self) -> CommentVariant
pub fn variant(&self) -> CommentVariant
The string variant type, see CommentVariant
for details.
Trait Implementations§
Source§impl Clone for TrimmedLiteral
impl Clone for TrimmedLiteral
Source§fn clone(&self) -> TrimmedLiteral
fn clone(&self) -> TrimmedLiteral
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TrimmedLiteral
impl Debug for TrimmedLiteral
Source§impl From<&TrimmedLiteral> for Span
impl From<&TrimmedLiteral> for Span
Source§fn from(literal: &TrimmedLiteral) -> Self
fn from(literal: &TrimmedLiteral) -> Self
Source§impl Hash for TrimmedLiteral
impl Hash for TrimmedLiteral
Source§impl PartialEq for TrimmedLiteral
impl PartialEq for TrimmedLiteral
impl Eq for TrimmedLiteral
Auto Trait Implementations§
impl Freeze for TrimmedLiteral
impl RefUnwindSafe for TrimmedLiteral
impl Send for TrimmedLiteral
impl Sync for TrimmedLiteral
impl Unpin for TrimmedLiteral
impl UnwindSafe for TrimmedLiteral
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more