Struct doc_chunks::literal::TrimmedLiteral
source · pub struct TrimmedLiteral { /* private fields */ }Expand description
A literal with meta info where the first and list whitespace may be found.
Implementations
sourceimpl 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).
sourceimpl 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 chars<'a>(&'a self) -> impl Iterator<Item = char> + 'a
pub fn chars<'a>(&'a self) -> impl Iterator<Item = char> + 'a
Access the characters via an iterator.
sourcepub fn variant(&self) -> CommentVariant
pub fn variant(&self) -> CommentVariant
The string variant type, see CommentVariant
for details.
Trait Implementations
sourceimpl Clone for TrimmedLiteral
impl Clone for TrimmedLiteral
sourcefn clone(&self) -> TrimmedLiteral
fn clone(&self) -> TrimmedLiteral
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresourceimpl Debug for TrimmedLiteral
impl Debug for TrimmedLiteral
sourceimpl From<&TrimmedLiteral> for Span
impl From<&TrimmedLiteral> for Span
sourcefn from(literal: &TrimmedLiteral) -> Self
fn from(literal: &TrimmedLiteral) -> Self
sourceimpl Hash for TrimmedLiteral
impl Hash for TrimmedLiteral
sourceimpl PartialEq<TrimmedLiteral> for TrimmedLiteral
impl PartialEq<TrimmedLiteral> for TrimmedLiteral
impl Eq for TrimmedLiteral
Auto Trait Implementations
impl RefUnwindSafe for TrimmedLiteral
impl Send for TrimmedLiteral
impl Sync for TrimmedLiteral
impl Unpin for TrimmedLiteral
impl UnwindSafe for TrimmedLiteral
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.