pub struct DiagSpan { /* private fields */ }Expand description
The span of a diagnostic message. Either from a Typst source file or from a loaded external file.
Typst source spans may additionally contain a sub-range targeting just part of the overall range of the span.
When storing an external file range, the maximum value of the start/end is
2^46-1, larger values are saturated.
This type is stored compactly in 16 bytes and null-optimized, but can be
expanded for easier usage as the DiagSpanKind enum via Self::get().
Implementations§
Source§impl DiagSpan
impl DiagSpan
Sourcepub const fn detached() -> Self
pub const fn detached() -> Self
The detached diagnostic span that does not point into any file.
Sourcepub fn from_range(id: FileId, range: Range<usize>) -> Self
pub fn from_range(id: FileId, range: Range<usize>) -> Self
Create a new diagnostic span from an external file’s byte range instead of an internal span.
If either of the range’s parts exceeds the maximum value of 2^46-1, it
will be saturated.
Sourcepub const fn is_detached(self) -> bool
pub const fn is_detached(self) -> bool
Whether the diagnostic span is detached.
Sourcepub fn id(self) -> Option<FileId>
pub fn id(self) -> Option<FileId>
The id of the file the span points into.
Returns None if the span is detached.
Sourcepub fn get(self) -> DiagSpanKind
pub fn get(self) -> DiagSpanKind
Unpack the diagnostic span into the variants of a DiagSpanKind for
easier use.
To access a range, you may want to use WorldExt::range instead.
Trait Implementations§
impl Copy for DiagSpan
impl Eq for DiagSpan
impl StructuralPartialEq for DiagSpan
Auto Trait Implementations§
impl Freeze for DiagSpan
impl RefUnwindSafe for DiagSpan
impl Send for DiagSpan
impl Sync for DiagSpan
impl Unpin for DiagSpan
impl UnsafeUnpin for DiagSpan
impl UnwindSafe for DiagSpan
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more