Struct nom_grapheme_clusters::source::Source
source · pub struct Source { /* private fields */ }
Expand description
A source code object, such as read from a file. Cloning this object results in simply incrementing a reference counter, thus sharing the source code object.
Implementations§
source§impl Source
impl Source
sourcepub fn new<S0, S1>(name: S0, contents: S1) -> Selfwhere
S0: Into<Box<str>>,
S1: Into<Box<str>>,
pub fn new<S0, S1>(name: S0, contents: S1) -> Selfwhere S0: Into<Box<str>>, S1: Into<Box<str>>,
Creates a new source code object given its name and its contents.
Contents are rearranged as grapheme clusters.
sourcepub fn seg_byte_indices(&self) -> SegmentByteIndices<'_> ⓘ
pub fn seg_byte_indices(&self) -> SegmentByteIndices<'_> ⓘ
Iterator over the segment indices of the source, where indices are in terms of bytes.
sourcepub fn newline_indices(&self) -> NewlineIndices<'_> ⓘ
pub fn newline_indices(&self) -> NewlineIndices<'_> ⓘ
Iterator over the newline indices of the source, where indices are in terms of segments/grapheme clusters.
sourcepub fn get<I>(&self, indexer: I) -> Option<&I::Output>where
I: SourceIndex,
pub fn get<I>(&self, indexer: I) -> Option<&I::Output>where I: SourceIndex,
Indexes this source. It can be a single usize
or a range of usize
.
Indices are given in terms of grapheme clusters/segments.
Trait Implementations§
source§impl<I> Index<I> for Sourcewhere
I: SourceIndex,
impl<I> Index<I> for Sourcewhere I: SourceIndex,
source§impl Ord for Source
impl Ord for Source
source§impl PartialEq<Source> for Source
impl PartialEq<Source> for Source
source§impl PartialOrd<Source> for Source
impl PartialOrd<Source> for Source
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Source
Auto Trait Implementations§
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnwindSafe for Source
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