pub struct Span { /* private fields */ }Expand description
Represents a span of source.
Implementations§
Source§impl Span
impl Span
Sourcepub const fn new(start: usize, len: usize) -> Span
pub const fn new(start: usize, len: usize) -> Span
Creates a new span from the given start and length.
Sourcepub fn contains(&self, offset: usize) -> bool
pub fn contains(&self, offset: usize) -> bool
Determines if the span contains the given offset.
Sourcepub fn intersect(self, other: Span) -> Option<Span>
pub fn intersect(self, other: Span) -> Option<Span>
Calculates an intersection of two spans, if one exists.
If spans are adjacent, a zero-length span is returned.
Returns None if the two spans are disjoint.
§Examples
assert_eq!(
Span::intersect(Span::new(0, 10), Span::new(5, 10)),
Some(Span::new(5, 5)),
);Trait Implementations§
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