Struct mm0_util::Span[][src]

pub struct Span {
    pub start: usize,
    pub end: usize,
}

Points to a specific region of a source file by identifying the region’s start and end points.

Fields

start: usize

The byte index of the beginning of the span (inclusive).

end: usize

The byte index of the end of the span (exclusive).

Methods from Deref<Target = Range<usize>>

pub fn contains<U>(&self, item: &U) -> bool where
    Idx: PartialOrd<U>,
    U: PartialOrd<Idx> + ?Sized
1.35.0[src]

Returns true if item is contained in the range.

Examples

assert!(!(3..5).contains(&2));
assert!( (3..5).contains(&3));
assert!( (3..5).contains(&4));
assert!(!(3..5).contains(&5));

assert!(!(3..3).contains(&3));
assert!(!(3..2).contains(&3));

assert!( (0.0..1.0).contains(&0.5));
assert!(!(0.0..1.0).contains(&f32::NAN));
assert!(!(0.0..f32::NAN).contains(&0.5));
assert!(!(f32::NAN..1.0).contains(&0.5));

pub fn is_empty(&self) -> bool1.47.0[src]

Returns true if the range contains no items.

Examples

assert!(!(3..5).is_empty());
assert!( (3..3).is_empty());
assert!( (3..2).is_empty());

The range is empty if either side is incomparable:

assert!(!(3.0..5.0).is_empty());
assert!( (3.0..f32::NAN).is_empty());
assert!( (f32::NAN..5.0).is_empty());

Trait Implementations

impl Clone for Span[src]

impl Copy for Span[src]

impl Debug for Span[src]

impl DeepSizeOf for Span[src]

impl Deref for Span[src]

type Target = Range<usize>

The resulting type after dereferencing.

impl DerefMut for Span[src]

impl Eq for Span[src]

impl<'a> From<&'a FileSpan> for Span[src]

impl From<Range<usize>> for Span[src]

impl From<RangeInclusive<usize>> for Span[src]

impl From<Span> for Range<usize>[src]

impl From<usize> for Span[src]

impl Hash for Span[src]

impl Index<Span> for LinedString[src]

Allows LinedString to be indexed with a Span, since Span is essentially a range.

type Output = [u8]

The returned type after indexing.

impl IntoIterator for Span[src]

type Item = usize

The type of the elements being iterated over.

type IntoIter = Range<usize>

Which kind of iterator are we turning this into?

impl PartialEq<Span> for Span[src]

impl StructuralEq for Span[src]

impl StructuralPartialEq for Span[src]

Auto Trait Implementations

impl RefUnwindSafe for Span

impl Send for Span

impl Sync for Span

impl Unpin for Span

impl UnwindSafe for Span

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.