pub struct PositionFinder<'a> { /* private fields */ }Expand description
Resolves many byte indices into the same text efficiently.
Building a PositionFinder precomputes the offset of every line start, so each
position lookup is O(log lines) instead of O(text len).
use index_to_position::PositionFinder;
let finder = PositionFinder::new("foo\nbar\nbaz");
assert_eq!((finder.position(0).line, finder.position(9).line), (0, 2));Implementations§
Source§impl<'a> PositionFinder<'a>
impl<'a> PositionFinder<'a>
Sourcepub fn with_options(text: &'a str, options: Options) -> Self
pub fn with_options(text: &'a str, options: Options) -> Self
Build a finder over text with the given Options.
Trait Implementations§
Source§impl<'a> Clone for PositionFinder<'a>
impl<'a> Clone for PositionFinder<'a>
Source§fn clone(&self) -> PositionFinder<'a>
fn clone(&self) -> PositionFinder<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for PositionFinder<'a>
impl<'a> RefUnwindSafe for PositionFinder<'a>
impl<'a> Send for PositionFinder<'a>
impl<'a> Sync for PositionFinder<'a>
impl<'a> Unpin for PositionFinder<'a>
impl<'a> UnsafeUnpin for PositionFinder<'a>
impl<'a> UnwindSafe for PositionFinder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more