Struct nu_source::Span [−][src]
pub struct Span { /* fields omitted */ }
Expand description
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.
Implementations
impl Span
[src]
impl Span
[src]pub fn from_list(list: &[impl HasSpan]) -> Span
[src]
pub fn new(start: usize, end: usize) -> Span
[src]
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]
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]
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(8), false); assert_eq!(span.contains(100), false);
pub fn since(&self, other: impl Into<Span>) -> Span
[src]
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]
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]
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(&self, source: &str) -> String
[src]
pub fn spanned_slice<'a>(&self, source: &'a str) -> Spanned<&'a str>
[src]
pub fn spanned_string(&self, source: &str) -> Spanned<String>
[src]
pub fn is_unknown(&self) -> bool
[src]
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);
Trait Implementations
impl<'de> Deserialize<'de> for Span
[src]
impl<'de> Deserialize<'de> for Span
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
impl Ord for Span
[src]
impl Ord for Span
[src]impl PartialOrd<Span> for Span
[src]
impl PartialOrd<Span> for Span
[src]fn partial_cmp(&self, other: &Span) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Span) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl PartialOrd<usize> for Span
[src]
impl PartialOrd<usize> for Span
[src]fn partial_cmp(&self, other: &usize) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &usize) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl PrettyDebugWithSource for Span
[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 Copy for Span
[src]
impl Eq for Span
[src]
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,