#[repr(C)]pub struct Span {
pub start: usize,
pub end: usize,
pub line: usize,
}Expand description
A half-open range which indicates the location of something in a body of text.
Fields§
§start: usizeThe byte index corresponding to the item’s start.
end: usizeThe index one byte past the item’s end.
line: usizeThe (zero-based) line number.
Implementations§
Source§impl Span
impl Span
Sourcepub const PLACEHOLDER: Span
pub const PLACEHOLDER: Span
A placeholder Span which will be ignored by Span::merge() and
equality checks.
Sourcepub fn get_text<'input>(&self, src: &'input str) -> Option<&'input str>
pub fn get_text<'input>(&self, src: &'input str) -> Option<&'input str>
Get the string this Span corresponds to.
Passing in a different string will probably lead to… strange… results.
Sourcepub fn merge(self, other: Span) -> Span
pub fn merge(self, other: Span) -> Span
Merge two Spans, making sure Span::PLACEHOLDER spans go away.
Sourcepub fn is_placeholder(self) -> bool
pub fn is_placeholder(self) -> bool
Is this a Span::PLACEHOLDER?
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Span
impl<'de> Deserialize<'de> for Span
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Span
impl Eq 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