pub struct IndexMap { /* private fields */ }Expand description
The map between the two index spaces of
TextPage.
A table of segments, not an index: it converts a character index into a text offset and back, so a caller never has to guess which of the two sequences a number counts in.
Implementations§
Source§impl IndexMap
impl IndexMap
Sourcepub fn segments(&self) -> &[CharSegment]
pub fn segments(&self) -> &[CharSegment]
The segments, oldest first.
Sourcepub fn char_index(&self, text_index: TextIndex) -> Option<CharIndex>
pub fn char_index(&self, text_index: TextIndex) -> Option<CharIndex>
The character index a text offset names.
let map = IndexMap::default();
assert_eq!(map.char_index(TextIndex::new(0)), None);Sourcepub fn text_index(&self, char_index: CharIndex) -> Option<TextIndex>
pub fn text_index(&self, char_index: CharIndex) -> Option<TextIndex>
The text offset a character index names, or None for a character the
text does not hold.
Sourcepub fn text_index_at_or_after(&self, char_index: CharIndex) -> Option<TextIndex>
pub fn text_index_at_or_after(&self, char_index: CharIndex) -> Option<TextIndex>
The text offset a character index names, rounded forward to the next character the text does hold.
What a start bound wants: a request that begins on a stripped character should begin at the next real one rather than failing.
Sourcepub fn text_index_end(&self, char_index: CharIndex) -> TextIndex
pub fn text_index_end(&self, char_index: CharIndex) -> TextIndex
The text offset one past the last text character at or before
char_index, which is what an end bound wants.
Trait Implementations§
impl Eq for IndexMap
impl StructuralPartialEq for IndexMap
Auto Trait Implementations§
impl Freeze for IndexMap
impl RefUnwindSafe for IndexMap
impl Send for IndexMap
impl Sync for IndexMap
impl Unpin for IndexMap
impl UnsafeUnpin for IndexMap
impl UnwindSafe for IndexMap
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