pub struct ChangeSet { /* private fields */ }Expand description
Sorted, non-overlapping, non-touching edits against a document of base_len
bytes.
Implementations§
Source§impl ChangeSet
impl ChangeSet
Sourcepub fn new(base_len: ByteOffset, edits: Vec<Edit>) -> Self
pub fn new(base_len: ByteOffset, edits: Vec<Edit>) -> Self
Sorts the edits and merges touching ones (concatenating their text) and overlapping deletions. Overlapping edits that both insert text are a caller bug.
pub fn edits(&self) -> &[Edit]
pub fn is_empty(&self) -> bool
pub fn base_len(&self) -> ByteOffset
pub fn new_len(&self) -> ByteOffset
Sourcepub fn apply(&self, doc: &mut Document)
pub fn apply(&self, doc: &mut Document)
Applies the edits to doc, which must be in the base state.
Sourcepub fn invert(&self, doc: &Document) -> ChangeSet
pub fn invert(&self, doc: &Document) -> ChangeSet
The change set that undoes this one. doc must be in the base state.
Sourcepub fn map_position(&self, pos: ByteOffset, bias: Bias) -> ByteOffset
pub fn map_position(&self, pos: ByteOffset, bias: Bias) -> ByteOffset
Maps a position in the base state to the new state.
Positions inside a replaced range move to its start (Before) or to the
end of the replacement (After). A position at the start of a non-empty
replaced range stays before it and one at its end stays after it,
whatever the bias; the bias only decides ties at pure insertions and
positions strictly inside a replaced range.
Trait Implementations§
impl Eq for ChangeSet
impl StructuralPartialEq for ChangeSet
Auto Trait Implementations§
impl Freeze for ChangeSet
impl RefUnwindSafe for ChangeSet
impl Send for ChangeSet
impl Sync for ChangeSet
impl Unpin for ChangeSet
impl UnsafeUnpin for ChangeSet
impl UnwindSafe for ChangeSet
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