Struct nom_grapheme_clusters::Location
source · pub struct Location { /* private fields */ }
Expand description
The location in a source code.
Implementations§
source§impl Location
impl Location
sourcepub fn new(source: Source, position: usize) -> Self
pub fn new(source: Source, position: usize) -> Self
Creates a new location given the source code object and position index.
Panics
Panics if position
is past beyond source length in number of segments.
sourcepub fn position(&self) -> usize
pub fn position(&self) -> usize
This location’s position in the source code in terms of grapheme clusters/segments.
sourcepub fn line_column(&self) -> (usize, usize)
pub fn line_column(&self) -> (usize, usize)
Finds the line and column (respectively) of this location in the source code. Line and column count grapheme clusters/segments, not bytes nor characters.
sourcepub fn line(&self) -> usize
pub fn line(&self) -> usize
Finds the line of this location in the source code. Line counts grapheme clusters/segments, not bytes nor characters.
sourcepub fn column(&self) -> usize
pub fn column(&self) -> usize
Finds the column of this location in the source code. Column counts grapheme clusters/segments, not bytes nor characters.
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the underlying grapheme cluster segment content at this location.
sourcepub fn segment(&self) -> LocatedSegment
pub fn segment(&self) -> LocatedSegment
Returns the single segmented pointed by this location.
Trait Implementations§
source§impl Ord for Location
impl Ord for Location
source§impl PartialEq<Location> for Location
impl PartialEq<Location> for Location
source§impl PartialOrd<Location> for Location
impl PartialOrd<Location> for Location
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