pub struct PosMap { /* private fields */ }Expand description
A flat position map over a batch of disjoint replacements, mapping pre-edit positions to post-edit ones. See the module docs.
Implementations§
Source§impl PosMap
impl PosMap
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this map is the identity — it holds no steps, so every position maps to itself. (A same-length step still counts: it maps interior positions to an edge, so it is not empty.)
Sourcepub fn push(&mut self, start: usize, old_len: usize, new_len: usize)
pub fn push(&mut self, start: usize, old_len: usize, new_len: usize)
Record a replacement: [start, start + old_len) (old coords) became
new_len units. A no-op span (old_len == new_len == 0) is ignored.
Steps are expected disjoint; they’re kept sorted by start.
Sourcepub fn map(&self, pos: usize, assoc: Assoc) -> usize
pub fn map(&self, pos: usize, assoc: Assoc) -> usize
Map a flat position from pre-edit to post-edit coordinates. assoc
decides which edge a position inside a replaced span lands on.
Sourcepub fn map_range(&self, range: PosRange, assoc: Assoc) -> PosRange
pub fn map_range(&self, range: PosRange, assoc: Assoc) -> PosRange
Map both endpoints of a PosRange with the same assoc (so a
collapsed range stays collapsed).
Sourcepub fn from_pos_edits(edits: &[PosEdit]) -> Self
pub fn from_pos_edits(edits: &[PosEdit]) -> Self
Build a map from a disjoint batch of edits (the same batch passed to
apply_pos_edits). Positions are taken in
the pre-edit coordinate system; mark/attr edits contribute no step.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PosMap
impl<'de> Deserialize<'de> for PosMap
Source§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>,
impl Eq for PosMap
impl StructuralPartialEq for PosMap
Auto Trait Implementations§
impl Freeze for PosMap
impl RefUnwindSafe for PosMap
impl Send for PosMap
impl Sync for PosMap
impl Unpin for PosMap
impl UnsafeUnpin for PosMap
impl UnwindSafe for PosMap
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.