[−][src]Struct nu_source::Span
A Span
is metadata which indicates the start and end positions.
Span
s are combined with AnchorLocation
s to form another type of metadata, a Tag
.
A Span
's end position must be greater than or equal to its start position.
Methods
impl Span
[src]
pub fn default() -> Self
[src]
Creates a default new Span
that has 0 start and 0 end.
pub fn unknown() -> Span
[src]
Creates a new Span
that has 0 start and 0 end.
pub fn new(start: usize, end: usize) -> Span
[src]
Creates a new Span
from start and end inputs. The end parameter must be greater than or equal to the start parameter.
pub fn for_char(pos: usize) -> Span
[src]
Creates a Span
with a length of 1 from the given position.
Example
let char_span = Span::for_char(5); assert_eq!(char_span.start(), 5); assert_eq!(char_span.end(), 6);
pub fn contains(&self, pos: usize) -> bool
[src]
Returns a bool indicating if the given position falls inside the current Span
.
Example
let span = Span::new(2, 8); assert_eq!(span.contains(5), true); assert_eq!(span.contains(100), false);
pub fn since(&self, other: impl Into<Span>) -> Span
[src]
Returns a new Span by merging an earlier Span with the current Span.
The resulting Span will have the same start position as the given Span and same end as the current Span.
Example
let original_span = Span::new(4, 6); let earlier_span = Span::new(1, 3); let merged_span = origin_span.since(earlier_span); assert_eq!(merged_span.start(), 1); assert_eq!(merged_span.end(), 6);
pub fn until(&self, other: impl Into<Span>) -> Span
[src]
Returns a new Span by merging a later Span with the current Span.
The resulting Span will have the same start position as the current Span and same end as the given Span.
Example
let original_span = Span::new(4, 6); let later_span = Span::new(9, 11); let merged_span = origin_span.until(later_span); assert_eq!(merged_span.start(), 4); assert_eq!(merged_span.end(), 11);
pub fn until_option(&self, other: Option<impl Into<Span>>) -> Span
[src]
Returns a new Span by merging a later Span with the current Span.
If the given Span is of the None variant, A Span with the same values as the current Span is returned.
pub fn string<'a>(&self, source: &'a str) -> String
[src]
pub fn spanned_slice<'a>(&self, source: &'a str) -> Spanned<&'a str>
[src]
pub fn spanned_string<'a>(&self, source: &'a str) -> Spanned<String>
[src]
pub fn start(&self) -> usize
[src]
Returns the start position of the current Span.
pub fn end(&self) -> usize
[src]
Returns the end position of the current Span.
pub fn is_unknown(&self) -> bool
[src]
Returns a bool if the current Span indicates an "unknown" position.
Example
let unknown_span = Span::unknown(); let known_span = Span::new(4, 6); assert_eq!(unknown_span.is_unknown(), true); assert_eq!(known_span.is_unknown(), false);
pub fn slice<'a>(&self, source: &'a str) -> &'a str
[src]
Returns a slice of the input that covers the start and end of the current Span.
Trait Implementations
impl Clone for Span
[src]
impl Copy for Span
[src]
impl Debug for Span
[src]
impl Default for Span
[src]
impl<'de> Deserialize<'de> for Span
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for Span
[src]
impl<'_> From<&'_ Range<usize>> for Span
[src]
impl<'_> From<&'_ Span> for Tag
[src]
impl<'_> From<&'_ Span> for Span
[src]
impl<'_> From<&'_ Tag> for Span
[src]
impl<T> From<(LocatedSpanEx<T, u64>, LocatedSpanEx<T, u64>)> for Span
[src]
fn from(input: (LocatedSpanEx<T, u64>, LocatedSpanEx<T, u64>)) -> Span
[src]
impl From<(usize, usize)> for Span
[src]
impl<'_, T> From<LocatedSpanEx<&'_ str, T>> for Span
[src]
fn from(input: LocatedSpanEx<&str, T>) -> Span
[src]
impl From<Option<Span>> for Span
[src]
impl From<Span> for Tag
[src]
impl From<Tag> for Span
[src]
impl HasSpan for Span
[src]
impl Hash for Span
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Span
[src]
fn cmp(&self, other: &Span) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Span> for Span
[src]
impl PartialEq<usize> for Span
[src]
impl PartialOrd<Span> for Span
[src]
fn partial_cmp(&self, other: &Span) -> Option<Ordering>
[src]
fn lt(&self, other: &Span) -> bool
[src]
fn le(&self, other: &Span) -> bool
[src]
fn gt(&self, other: &Span) -> bool
[src]
fn ge(&self, other: &Span) -> bool
[src]
impl PartialOrd<usize> for Span
[src]
fn partial_cmp(&self, other: &usize) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PrettyDebugWithSource for Span
[src]
fn pretty_debug(&self, source: &str) -> DebugDocBuilder
[src]
fn refined_pretty_debug(
&self,
_refine: PrettyDebugRefineKind,
source: &str
) -> DebugDocBuilder
[src]
&self,
_refine: PrettyDebugRefineKind,
source: &str
) -> DebugDocBuilder
fn debug(&self, source: impl Into<Text>) -> String where
Self: Clone,
[src]
Self: Clone,
fn debuggable(self, source: impl Into<Text>) -> DebuggableWithSource<Self>
[src]
impl ReportingSpan for Span
[src]
fn with_start(&self, start: usize) -> Self
[src]
fn with_end(&self, end: usize) -> Self
[src]
fn start(&self) -> usize
[src]
fn end(&self) -> usize
[src]
impl Serialize for Span
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for Span
[src]
impl StructuralPartialEq for Span
[src]
Auto Trait Implementations
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnwindSafe for Span
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,