pub struct Span { /* private fields */ }
Expand description
Represents a range of text within a document, as a Start and End offset.
Effectively two SourceOffsets in one struct.
Implementations§
Source§impl Span
impl Span
Sourcepub const DUMMY: Span
pub const DUMMY: Span
Represents a fake Span with SourceOffset::DUMMY as the start/end offsets.
pub const ZERO: Span
Sourcepub const fn new(start: SourceOffset, end: SourceOffset) -> Span
pub const fn new(start: SourceOffset, end: SourceOffset) -> Span
Creates a new Span given a starting SourceOffset and an ending SourceOffset.
Asserts: start <= end
Sourcepub const fn start(&self) -> SourceOffset
pub const fn start(&self) -> SourceOffset
Gets the starting SourceOffset.
Sourcepub const fn end(&self) -> SourceOffset
pub const fn end(&self) -> SourceOffset
Gets the ending SourceOffset.
Sourcepub fn with_end(self, end: SourceOffset) -> Span
pub fn with_end(self, end: SourceOffset) -> Span
Extends this Span into a new one with the end altered to be SourceOffset.
Asserts: start <= end
Sourcepub fn line_and_column(self, source: &str) -> (u32, u32)
pub fn line_and_column(self, source: &str) -> (u32, u32)
Given a string source
, establish the line number and column number that this span would reside in.
Trait Implementations§
Source§impl Add for Span
Extends this Span, ensuring that the resulting new Span is broader than both this and the given Span.
In other words the resulting span will always Span::contains() both Spans.
impl Add for Span
Extends this Span, ensuring that the resulting new Span is broader than both this and the given Span. In other words the resulting span will always Span::contains() both Spans.
Source§impl Ord for Span
impl Ord for Span
Source§impl PartialOrd for Span
impl PartialOrd for Span
impl Copy for Span
impl Eq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnwindSafe for Span
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