Struct nom_grapheme_clusters::span::Span
source · pub struct Span { /* private fields */ }
Expand description
A span (a range) in the source code.
It can be created with the constructor Span::new
, or with
Source::full_span
.
Implementations§
source§impl Span
impl Span
sourcepub fn new(start: Location, length: usize) -> Self
pub fn new(start: Location, length: usize) -> Self
Creates a new span given the start location and length.
Panics
Panics if length
is too big, i.e. start.position() + length > start.source().len()
.
sourcepub fn from_range(start: Location, end: Location) -> Self
pub fn from_range(start: Location, end: Location) -> Self
Creates a new span from a range of locations, where end
is exlusive.
Panics
Panics if start
and end
point to different sources, or if start
is
past beyond end
.
sourcepub fn from_range_inclusive(start: Location, end: Location) -> Self
pub fn from_range_inclusive(start: Location, end: Location) -> Self
Creates a new span from a range of locations, where end
is inclusive.
Panics
Panics if start
and end
point to different sources, or if start
is
the same or beyond end
.
sourcepub fn content(&self) -> SpanContent
pub fn content(&self) -> SpanContent
Creates a type that, when displayed, shows the span contents, rather than location.
sourcepub fn expand_lines(&self) -> Span
pub fn expand_lines(&self) -> Span
Expands this span in order to contain the whole lines the original span contains.
sourcepub fn try_slice<R>(&self, range: R) -> Option<Self>where
R: RangeBounds<usize>,
pub fn try_slice<R>(&self, range: R) -> Option<Self>where R: RangeBounds<usize>,
Slices this span to the given range. Returns None
if the range is
invalid.
sourcepub fn segments(&self) -> Segments ⓘ
pub fn segments(&self) -> Segments ⓘ
Creates an iterator over located grapheme cluster segments, namely
LocatedSegment
s.
sourcepub fn indexed_segments(&self) -> IndexedSegments ⓘ
pub fn indexed_segments(&self) -> IndexedSegments ⓘ
Creates an IndexedSegments
iterator, which yields a tuple of
position and a LocatedSegment
in that position. Note that this is
just for convenience with e.g. nom, LocatedSegment
already contains
its position, and so Segments
can be used.
Trait Implementations§
source§impl<'this, 'input> Compare<&'input Span> for &'this Span
impl<'this, 'input> Compare<&'input Span> for &'this Span
source§fn compare(&self, input: &'input Span) -> CompareResult
fn compare(&self, input: &'input Span) -> CompareResult
source§fn compare_no_case(&self, input: &'input Span) -> CompareResult
fn compare_no_case(&self, input: &'input Span) -> CompareResult
source§impl<'this, 'input> Compare<&'input Span> for &'this SpanContent
impl<'this, 'input> Compare<&'input Span> for &'this SpanContent
source§fn compare(&self, input: &'input Span) -> CompareResult
fn compare(&self, input: &'input Span) -> CompareResult
source§fn compare_no_case(&self, input: &'input Span) -> CompareResult
fn compare_no_case(&self, input: &'input Span) -> CompareResult
source§impl<'input> Compare<&'input Span> for Span
impl<'input> Compare<&'input Span> for Span
source§fn compare(&self, input: &'input Span) -> CompareResult
fn compare(&self, input: &'input Span) -> CompareResult
source§fn compare_no_case(&self, input: &'input Span) -> CompareResult
fn compare_no_case(&self, input: &'input Span) -> CompareResult
source§impl<'input> Compare<&'input Span> for SpanContent
impl<'input> Compare<&'input Span> for SpanContent
source§fn compare(&self, input: &'input Span) -> CompareResult
fn compare(&self, input: &'input Span) -> CompareResult
source§fn compare_no_case(&self, input: &'input Span) -> CompareResult
fn compare_no_case(&self, input: &'input Span) -> CompareResult
source§impl<'this, 'input> Compare<&'input SpanContent> for &'this Span
impl<'this, 'input> Compare<&'input SpanContent> for &'this Span
source§fn compare(&self, input: &'input SpanContent) -> CompareResult
fn compare(&self, input: &'input SpanContent) -> CompareResult
source§fn compare_no_case(&self, input: &'input SpanContent) -> CompareResult
fn compare_no_case(&self, input: &'input SpanContent) -> CompareResult
source§impl<'input> Compare<&'input SpanContent> for Span
impl<'input> Compare<&'input SpanContent> for Span
source§fn compare(&self, input: &'input SpanContent) -> CompareResult
fn compare(&self, input: &'input SpanContent) -> CompareResult
source§fn compare_no_case(&self, input: &'input SpanContent) -> CompareResult
fn compare_no_case(&self, input: &'input SpanContent) -> CompareResult
source§impl<'slice, 'seg, 'span> Compare<&'span Span> for Tag<'slice, 'seg>
impl<'slice, 'seg, 'span> Compare<&'span Span> for Tag<'slice, 'seg>
source§fn compare(&self, input: &'span Span) -> CompareResult
fn compare(&self, input: &'span Span) -> CompareResult
source§fn compare_no_case(&self, input: &'span Span) -> CompareResult
fn compare_no_case(&self, input: &'span Span) -> CompareResult
source§impl<'slice, 'seg, 'tag, 'span> Compare<&'tag Tag<'slice, 'seg>> for &'span Span
impl<'slice, 'seg, 'tag, 'span> Compare<&'tag Tag<'slice, 'seg>> for &'span Span
source§fn compare(&self, input: &'tag Tag<'slice, 'seg>) -> CompareResult
fn compare(&self, input: &'tag Tag<'slice, 'seg>) -> CompareResult
source§fn compare_no_case(&self, input: &'tag Tag<'slice, 'seg>) -> CompareResult
fn compare_no_case(&self, input: &'tag Tag<'slice, 'seg>) -> CompareResult
source§impl<'slice, 'seg, 'tag> Compare<&'tag Tag<'slice, 'seg>> for Span
impl<'slice, 'seg, 'tag> Compare<&'tag Tag<'slice, 'seg>> for Span
source§fn compare(&self, input: &'tag Tag<'slice, 'seg>) -> CompareResult
fn compare(&self, input: &'tag Tag<'slice, 'seg>) -> CompareResult
source§fn compare_no_case(&self, input: &'tag Tag<'slice, 'seg>) -> CompareResult
fn compare_no_case(&self, input: &'tag Tag<'slice, 'seg>) -> CompareResult
source§impl<'this> Compare<Span> for &'this Span
impl<'this> Compare<Span> for &'this Span
source§fn compare(&self, input: Span) -> CompareResult
fn compare(&self, input: Span) -> CompareResult
source§fn compare_no_case(&self, input: Span) -> CompareResult
fn compare_no_case(&self, input: Span) -> CompareResult
source§impl<'this> Compare<Span> for &'this SpanContent
impl<'this> Compare<Span> for &'this SpanContent
source§fn compare(&self, input: Span) -> CompareResult
fn compare(&self, input: Span) -> CompareResult
source§fn compare_no_case(&self, input: Span) -> CompareResult
fn compare_no_case(&self, input: Span) -> CompareResult
source§impl Compare<Span> for Span
impl Compare<Span> for Span
source§fn compare(&self, input: Span) -> CompareResult
fn compare(&self, input: Span) -> CompareResult
source§fn compare_no_case(&self, input: Span) -> CompareResult
fn compare_no_case(&self, input: Span) -> CompareResult
source§impl Compare<Span> for SpanContent
impl Compare<Span> for SpanContent
source§fn compare(&self, input: Span) -> CompareResult
fn compare(&self, input: Span) -> CompareResult
source§fn compare_no_case(&self, input: Span) -> CompareResult
fn compare_no_case(&self, input: Span) -> CompareResult
source§impl<'slice, 'seg, 'span> Compare<Span> for Tag<'slice, 'seg>
impl<'slice, 'seg, 'span> Compare<Span> for Tag<'slice, 'seg>
source§fn compare(&self, input: Span) -> CompareResult
fn compare(&self, input: Span) -> CompareResult
source§fn compare_no_case(&self, input: Span) -> CompareResult
fn compare_no_case(&self, input: Span) -> CompareResult
source§impl<'this> Compare<SpanContent> for &'this Span
impl<'this> Compare<SpanContent> for &'this Span
source§fn compare(&self, input: SpanContent) -> CompareResult
fn compare(&self, input: SpanContent) -> CompareResult
source§fn compare_no_case(&self, input: SpanContent) -> CompareResult
fn compare_no_case(&self, input: SpanContent) -> CompareResult
source§impl Compare<SpanContent> for Span
impl Compare<SpanContent> for Span
source§fn compare(&self, input: SpanContent) -> CompareResult
fn compare(&self, input: SpanContent) -> CompareResult
source§fn compare_no_case(&self, input: SpanContent) -> CompareResult
fn compare_no_case(&self, input: SpanContent) -> CompareResult
source§impl<'slice, 'seg, 'span> Compare<Tag<'slice, 'seg>> for &'span Span
impl<'slice, 'seg, 'span> Compare<Tag<'slice, 'seg>> for &'span Span
source§fn compare(&self, input: Tag<'slice, 'seg>) -> CompareResult
fn compare(&self, input: Tag<'slice, 'seg>) -> CompareResult
source§fn compare_no_case(&self, input: Tag<'slice, 'seg>) -> CompareResult
fn compare_no_case(&self, input: Tag<'slice, 'seg>) -> CompareResult
source§impl<'slice, 'seg> Compare<Tag<'slice, 'seg>> for Span
impl<'slice, 'seg> Compare<Tag<'slice, 'seg>> for Span
source§fn compare(&self, input: Tag<'slice, 'seg>) -> CompareResult
fn compare(&self, input: Tag<'slice, 'seg>) -> CompareResult
source§fn compare_no_case(&self, input: Tag<'slice, 'seg>) -> CompareResult
fn compare_no_case(&self, input: Tag<'slice, 'seg>) -> CompareResult
source§impl<'this, 'tok> FindToken<&'tok LocatedSegment> for &'this Span
impl<'this, 'tok> FindToken<&'tok LocatedSegment> for &'this Span
source§fn find_token(&self, token: &'tok LocatedSegment) -> bool
fn find_token(&self, token: &'tok LocatedSegment) -> bool
source§impl<'tok> FindToken<&'tok LocatedSegment> for Span
impl<'tok> FindToken<&'tok LocatedSegment> for Span
source§fn find_token(&self, token: &'tok LocatedSegment) -> bool
fn find_token(&self, token: &'tok LocatedSegment) -> bool
source§impl<'this, 'tok> FindToken<&'tok str> for &'this Span
impl<'this, 'tok> FindToken<&'tok str> for &'this Span
source§fn find_token(&self, token: &'tok str) -> bool
fn find_token(&self, token: &'tok str) -> bool
source§impl<'tok> FindToken<&'tok str> for Span
impl<'tok> FindToken<&'tok str> for Span
source§fn find_token(&self, token: &'tok str) -> bool
fn find_token(&self, token: &'tok str) -> bool
source§impl<'this, 'tok, 'tok_ref> FindToken<&'tok_ref &'tok str> for &'this Span
impl<'this, 'tok, 'tok_ref> FindToken<&'tok_ref &'tok str> for &'this Span
source§fn find_token(&self, token: &'tok_ref &'tok str) -> bool
fn find_token(&self, token: &'tok_ref &'tok str) -> bool
source§impl<'tok, 'tok_ref> FindToken<&'tok_ref &'tok str> for Span
impl<'tok, 'tok_ref> FindToken<&'tok_ref &'tok str> for Span
source§fn find_token(&self, token: &'tok_ref &'tok str) -> bool
fn find_token(&self, token: &'tok_ref &'tok str) -> bool
source§impl<'this, 'tok> FindToken<LocatedSegment> for &'this Span
impl<'this, 'tok> FindToken<LocatedSegment> for &'this Span
source§fn find_token(&self, token: LocatedSegment) -> bool
fn find_token(&self, token: LocatedSegment) -> bool
source§impl<'tok> FindToken<LocatedSegment> for Span
impl<'tok> FindToken<LocatedSegment> for Span
source§fn find_token(&self, token: LocatedSegment) -> bool
fn find_token(&self, token: LocatedSegment) -> bool
source§impl InputIter for Span
impl InputIter for Span
§type Item = LocatedSegment
type Item = LocatedSegment
Item
type. Read more§type Iter = Enumerate<<Span as InputIter>::IterElem>
type Iter = Enumerate<<Span as InputIter>::IterElem>
&str
, the position
corresponds to the byte index of the charactersource§fn iter_indices(&self) -> Self::Iter
fn iter_indices(&self) -> Self::Iter
source§fn iter_elements(&self) -> Self::IterElem
fn iter_elements(&self) -> Self::IterElem
source§impl<'this> InputLength for &'this Span
impl<'this> InputLength for &'this Span
source§impl InputLength for Span
impl InputLength for Span
source§impl InputTake for Span
impl InputTake for Span
source§fn take_split(&self, count: usize) -> (Self, Self)
fn take_split(&self, count: usize) -> (Self, Self)
count
byte offset. panics if count > lengthsource§impl InputTakeAtPosition for Span
impl InputTakeAtPosition for Span
§type Item = LocatedSegment
type Item = LocatedSegment
Item
type. Read moresource§fn split_at_position<P, E>(&self, predicate: P) -> IResult<Self, Self, E>where
P: Fn(Self::Item) -> bool,
E: ParseError<Self>,
fn split_at_position<P, E>(&self, predicate: P) -> IResult<Self, Self, E>where P: Fn(Self::Item) -> bool, E: ParseError<Self>,
source§fn split_at_position1<P, E>(
&self,
predicate: P,
e: ErrorKind
) -> IResult<Self, Self, E>where
P: Fn(Self::Item) -> bool,
E: ParseError<Self>,
fn split_at_position1<P, E>( &self, predicate: P, e: ErrorKind ) -> IResult<Self, Self, E>where P: Fn(Self::Item) -> bool, E: ParseError<Self>,
source§fn split_at_position_complete<P, E>(
&self,
predicate: P
) -> IResult<Self, Self, E>where
P: Fn(Self::Item) -> bool,
E: ParseError<Self>,
fn split_at_position_complete<P, E>( &self, predicate: P ) -> IResult<Self, Self, E>where P: Fn(Self::Item) -> bool, E: ParseError<Self>,
source§fn split_at_position1_complete<P, E>(
&self,
predicate: P,
e: ErrorKind
) -> IResult<Self, Self, E>where
P: Fn(Self::Item) -> bool,
E: ParseError<Self>,
fn split_at_position1_complete<P, E>( &self, predicate: P, e: ErrorKind ) -> IResult<Self, Self, E>where P: Fn(Self::Item) -> bool, E: ParseError<Self>,
source§impl IntoIterator for Span
impl IntoIterator for Span
source§impl Ord for Span
impl Ord for Span
source§impl PartialEq<Span> for Span
impl PartialEq<Span> for Span
source§impl PartialOrd<Span> for Span
impl PartialOrd<Span> for Span
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more