Struct debris_parser::LocalSpan
source · pub struct LocalSpan(pub Span);
Expand description
Wrapper over normal spans, to ensure that parser spans are not accidentally mixed with hir spans
Tuple Fields§
§0: Span
Methods from Deref<Target = Span>§
pub const EMPTY: Span = _
pub fn at_start(&self) -> Span
pub fn at_start(&self) -> Span
Returns a span with the same start and a length of one
pub fn until(&self, other: Span) -> Span
pub fn until(&self, other: Span) -> Span
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>
pub 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 LocalSpan
impl PartialEq for LocalSpan
impl Copy for LocalSpan
impl Eq for LocalSpan
impl StructuralEq for LocalSpan
impl StructuralPartialEq for LocalSpan
Auto Trait Implementations§
impl RefUnwindSafe for LocalSpan
impl Send for LocalSpan
impl Sync for LocalSpan
impl Unpin for LocalSpan
impl UnwindSafe for LocalSpan
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.