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) -> Self
pub fn new<S0, S1>(name: S0, contents: S1) -> Self
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§
impl Eq for Source
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
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Auto Trait Implementations§
impl Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnsafeUnpin 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