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
Creates a new Span
from start and end inputs. The end parameter must be greater than or equal to the start parameter.
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);
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);
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);
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);
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.
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);
Returns a bool if the current Span does not cover.
Example
// make clean
// ----
// (0,4)
//
// ^(5,5)
let make_span = Span::new(0,4);
let clean_span = Span::new(5,5);
assert_eq!(make_span.is_closed(), false);
assert_eq!(clean_span.is_closed(), true);
Trait Implementations
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
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn refined_pretty_debug(
&self,
_refine: PrettyDebugRefineKind,
source: &str
) -> DebugDocBuilder
Auto Trait Implementations
impl RefUnwindSafe for Span
impl UnwindSafe for Span
Blanket Implementations
Mutably borrows from an owned value. Read more