Struct debris_common::span::Span
source · pub struct Span {
start: usize,
len: usize,
}
Expand description
A span which uniquely specifies a span of characters in their corresponding file
All spans are dependent on the InputFiles
which contains the file
that spans can refer to.
Fields§
§start: usize
§len: usize
Implementations§
source§impl Span
impl Span
pub const EMPTY: Span = _
sourcepub const fn new(start: usize, len: usize) -> Self
pub const fn new(start: usize, len: usize) -> Self
Creates a new Span
from the starting character and its length
sourcepub fn until(&self, other: Span) -> Self
pub fn until(&self, other: Span) -> Self
Constructs a new span which ranges from the start of this span to the end of the other span
pub fn as_slice(&self) -> Range<usize>
sourcepub fn char_bounds(&self, source: &str) -> (usize, usize)
pub fn char_bounds(&self, source: &str) -> (usize, usize)
Since ranges are used to index into a str on a byte level, a span starting at index 10 is not necessarily the character at index 10. This methods iterates over the source chars until it finds the character at the byte positions marked by this span. This methods panics if the span is out of bounds.
Returns:
The returned tuple has the shape (start_character_index
, end_character_index
)
Trait Implementations§
source§impl PartialEq for Span
impl PartialEq for Span
impl Copy for Span
impl Eq for Span
impl StructuralEq for Span
impl StructuralPartialEq for Span
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§
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.