pub struct Span {
pub file: FileId,
pub start: u32,
pub end: u32,
}Fields§
§file: FileId§start: u32§end: u32Implementations§
Source§impl Span
impl Span
pub const fn new( file: FileId, start: u32, end: u32, ) -> Result<Self, SourceError>
pub fn text(self, source: &str, file: FileId) -> Result<&str, SourceError>
Sourcepub const fn at(file: FileId) -> Self
pub const fn at(file: FileId) -> Self
A zero-length placeholder anchored to file — for definitions and
generated nodes that have a logical home file but no source range
(prelude/stdlib declarations, desugared temporaries). The home is always
named explicitly: a reserved id for prelude/stdlib, the script’s id for
compiler-generated user-code nodes.
Sourcepub fn first_line_of(self, text: &str) -> Self
pub fn first_line_of(self, text: &str) -> Self
This span cut to its first line of text, its file’s source; unchanged
when it is not a range of text. A line ends at \n or \r, as in
LineIndex.
Sourcepub const fn is_placeholder(self) -> bool
pub const fn is_placeholder(self) -> bool
Whether this is a Self::at placeholder, which locates nothing.
pub fn merge(self, other: Self) -> Result<Self, SourceError>
pub fn contains(self, offset: u32) -> bool
Trait Implementations§
impl Copy for Span
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 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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.