pub struct CodeSpan {
pub src: InputSrc,
pub start: Loc,
pub end: Loc,
}
Expand description
A span in a Uiua source file
Fields§
§src: InputSrc
The path of the file
start: Loc
The starting location
end: Loc
The ending location
Implementations§
Source§impl CodeSpan
impl CodeSpan
Sourcepub fn literal(s: impl Into<EcoString>) -> CodeSpan
pub fn literal(s: impl Into<EcoString>) -> CodeSpan
Create a span which contains its own source
Sourcepub fn char_count(&self) -> u32
pub fn char_count(&self) -> u32
Get the number of characters in the span
Sourcepub fn merge_with(&mut self, end: CodeSpan)
pub fn merge_with(&mut self, end: CodeSpan)
Merge two spans
Sourcepub fn end_to(self, other: &CodeSpan) -> CodeSpan
pub fn end_to(self, other: &CodeSpan) -> CodeSpan
Get the span between this span and another after it
Sourcepub fn byte_range(&self) -> Range<usize>
pub fn byte_range(&self) -> Range<usize>
Get the text of the span
Sourcepub fn contains_line_col(&self, line: usize, col: usize) -> bool
pub fn contains_line_col(&self, line: usize, col: usize) -> bool
Check if the span contains a line and column
Excludes the end column
Sourcepub fn contains_line_col_end(&self, line: usize, col: usize) -> bool
pub fn contains_line_col_end(&self, line: usize, col: usize) -> bool
Check if the span contains a line and column
Includes the end column
Sourcepub fn as_str<T>(&self, inputs: &Inputs, f: impl FnOnce(&str) -> T) -> T
pub fn as_str<T>(&self, inputs: &Inputs, f: impl FnOnce(&str) -> T) -> T
Get the text of the span from the inputs
Sourcepub fn before_str<T>(&self, inputs: &Inputs, f: impl FnOnce(&str) -> T) -> T
pub fn before_str<T>(&self, inputs: &Inputs, f: impl FnOnce(&str) -> T) -> T
Get the text before the span from the inputs
Sourcepub fn try_as_str<T>(
&self,
inputs: &Inputs,
f: impl FnOnce(&str) -> T,
) -> Option<T>
pub fn try_as_str<T>( &self, inputs: &Inputs, f: impl FnOnce(&str) -> T, ) -> Option<T>
Get the text of the span from the inputs
Sourcepub fn just_start(&self, inputs: &Inputs) -> CodeSpan
pub fn just_start(&self, inputs: &Inputs) -> CodeSpan
Get just the span of the first character
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CodeSpan
impl<'de> Deserialize<'de> for CodeSpan
Source§fn deserialize<D>(
deserializer: D,
) -> Result<CodeSpan, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<CodeSpan, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for CodeSpan
impl Ord for CodeSpan
Source§impl PartialOrd for CodeSpan
impl PartialOrd for CodeSpan
Source§impl Serialize for CodeSpan
impl Serialize for CodeSpan
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for CodeSpan
impl StructuralPartialEq for CodeSpan
Auto Trait Implementations§
impl Freeze for CodeSpan
impl RefUnwindSafe for CodeSpan
impl Send for CodeSpan
impl Sync for CodeSpan
impl Unpin for CodeSpan
impl UnwindSafe for CodeSpan
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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