pub struct Span<'a> { /* private fields */ }
Expand description
A Span is a set of meta information about the location of a substring.
Implementations§
Source§impl<'a> Span<'a>
impl<'a> Span<'a>
Sourcepub fn whole_content(&self) -> &'a str
pub fn whole_content(&self) -> &'a str
The whole content the Span
belongs to.
Sourcepub fn content_before(&self) -> &'a str
pub fn content_before(&self) -> &'a str
The content before the Span
.
Sourcepub fn content_after(&self) -> &'a str
pub fn content_after(&self) -> &'a str
The content after the Span
.
Sourcepub fn start_cursor(&self) -> &Cursor
pub fn start_cursor(&self) -> &Cursor
The start position of the Span
in bytes.
Sourcepub fn end_cursor(&self) -> &Cursor
pub fn end_cursor(&self) -> &Cursor
The end position of the Span
in bytes.
Sourcepub fn char_length(&self) -> usize
pub fn char_length(&self) -> usize
The length of the Span
in characters.
Sourcepub fn lines(&self) -> &'a str
pub fn lines(&self) -> &'a str
Returns the line(s) in which the Span
is contained.
If it is composed of more than one line, the result will be all the lines.
§Example
let mut reader = Reader::new("This\nis\nthe\nfragment");
// ... prepare the span to contain: "his\nis\nt" ...
let span = reader.substring(&from_cursor, &to_cursor);
// Get its lines.
assert_eq!(span.lines(), "This\nis\nthe");
Trait Implementations§
impl<'a> Eq for Span<'a>
impl<'a> StructuralPartialEq for Span<'a>
Auto Trait Implementations§
impl<'a> Freeze for Span<'a>
impl<'a> RefUnwindSafe for Span<'a>
impl<'a> Send for Span<'a>
impl<'a> Sync for Span<'a>
impl<'a> Unpin for Span<'a>
impl<'a> UnwindSafe for Span<'a>
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