pub struct Span {
pub start: usize,
pub end: usize,
}
Expand description
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>>§
1.35.0 · Sourcepub fn contains<U>(&self, item: &U) -> bool
pub fn contains<U>(&self, item: &U) -> bool
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));
1.47.0 · Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
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§
Source§impl DeepSizeOf for Span
impl DeepSizeOf for Span
Source§fn deep_size_of_children(&self, _: &mut Context) -> usize
fn deep_size_of_children(&self, _: &mut Context) -> usize
Returns an estimation of the heap-managed storage of this object.
This does not include the size of the object itself. Read more
Source§fn deep_size_of(&self) -> usize
fn deep_size_of(&self) -> usize
Returns an estimation of a total size of memory owned by the
object, including heap-managed storage. Read more
Source§fn deep_size_of_with(&self, context: &mut Context) -> usize
fn deep_size_of_with(&self, context: &mut Context) -> usize
Returns an estimation of a total size of memory owned by the
object, including heap-managed storage.
Source§impl From<RangeInclusive<usize>> for Span
impl From<RangeInclusive<usize>> for Span
Source§fn from(r: RangeInclusive<usize>) -> Self
fn from(r: RangeInclusive<usize>) -> Self
Converts to this type from the input type.
Source§impl Index<Span> for LinedString
Allows LinedString
to be indexed with a Span
, since Span
is essentially a range.
impl Index<Span> for LinedString
Allows LinedString
to be indexed with a Span
, since Span
is essentially a range.
Source§impl IntoIterator for Span
impl IntoIterator 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