Enum loro_delta::DeltaItem
source · pub enum DeltaItem<V, Attr> {
Retain {
len: usize,
attr: Attr,
},
Replace {
value: V,
attr: Attr,
delete: usize,
},
}
Variants§
Retain
Replace
This is the combined of a delete and an insert.
They are two separate operations in the original Quill Delta format. But the order of two neighboring delete and insert operations can be swapped without changing the result. So Quill requires that the insert always comes before the delete. So it creates room for invalid deltas by the type system. Using Replace is a way to avoid this.
Implementations§
source§impl<V: DeltaValue, Attr> DeltaItem<V, Attr>
impl<V: DeltaValue, Attr> DeltaItem<V, Attr>
source§impl<V: DeltaValue, Attr: Default> DeltaItem<V, Attr>
impl<V: DeltaValue, Attr: Default> DeltaItem<V, Attr>
pub fn new_delete(len: usize) -> Self
source§impl<V, Attr> DeltaItem<V, Attr>
impl<V, Attr> DeltaItem<V, Attr>
sourcepub fn as_retain_mut(&mut self) -> Option<(&mut usize, &mut Attr)>
pub fn as_retain_mut(&mut self) -> Option<(&mut usize, &mut Attr)>
Optionally returns mutable references to the inner fields if this is a DeltaItem::Retain
, otherwise None
sourcepub fn as_retain(&self) -> Option<(&usize, &Attr)>
pub fn as_retain(&self) -> Option<(&usize, &Attr)>
Optionally returns references to the inner fields if this is a DeltaItem::Retain
, otherwise None
sourcepub fn into_retain(self) -> Result<(usize, Attr), Self>
pub fn into_retain(self) -> Result<(usize, Attr), Self>
Returns the inner fields if this is a DeltaItem::Retain
, otherwise returns back the enum in the Err
case of the result
sourcepub fn as_replace_mut(&mut self) -> Option<(&mut V, &mut Attr, &mut usize)>
pub fn as_replace_mut(&mut self) -> Option<(&mut V, &mut Attr, &mut usize)>
Optionally returns mutable references to the inner fields if this is a DeltaItem::Replace
, otherwise None
sourcepub fn as_replace(&self) -> Option<(&V, &Attr, &usize)>
pub fn as_replace(&self) -> Option<(&V, &Attr, &usize)>
Optionally returns references to the inner fields if this is a DeltaItem::Replace
, otherwise None
sourcepub fn into_replace(self) -> Result<(V, Attr, usize), Self>
pub fn into_replace(self) -> Result<(V, Attr, usize), Self>
Returns the inner fields if this is a DeltaItem::Replace
, otherwise returns back the enum in the Err
case of the result
Trait Implementations§
source§impl<V: DeltaValue, Attr: Clone> CanRemove for DeltaItem<V, Attr>
impl<V: DeltaValue, Attr: Clone> CanRemove for DeltaItem<V, Attr>
fn can_remove(&self) -> bool
source§impl<V: DeltaValue, Attr> HasLength for DeltaItem<V, Attr>
impl<V: DeltaValue, Attr> HasLength for DeltaItem<V, Attr>
source§impl<V: PartialEq, Attr: PartialEq> PartialEq for DeltaItem<V, Attr>
impl<V: PartialEq, Attr: PartialEq> PartialEq for DeltaItem<V, Attr>
source§impl<V: DeltaValue, Attr: DeltaAttr> Sliceable for DeltaItem<V, Attr>
impl<V: DeltaValue, Attr: DeltaAttr> Sliceable for DeltaItem<V, Attr>
source§fn slice_(&mut self, range: impl RangeBounds<usize>)
fn slice_(&mut self, range: impl RangeBounds<usize>)
slice in-place
source§fn update_with_split(
&mut self,
range: impl RangeBounds<usize>,
f: impl FnOnce(&mut Self)
) -> (Option<Self>, Option<Self>)
fn update_with_split( &mut self, range: impl RangeBounds<usize>, f: impl FnOnce(&mut Self) ) -> (Option<Self>, Option<Self>)
Update the slice in the given range.
This method may split self
into two or three parts.
If so, it will make self
the leftmost part and return the next split parts.
§Example
If self.rle_len() == 10
, self.update(1..5)
will split self into three parts and update the middle part.
It returns the middle and the right part.
fn _slice(&self, range: Range<usize>) -> Self
fn split(&mut self, pos: usize) -> Self
fn slice(&self, range: impl RangeBounds<usize>) -> Self
impl<V: DeltaValue, Attr: DeltaAttr> DeltaValue for DeltaItem<V, Attr>
impl<V: Eq, Attr: Eq> Eq for DeltaItem<V, Attr>
impl<V, Attr> StructuralPartialEq for DeltaItem<V, Attr>
Auto Trait Implementations§
impl<V, Attr> Freeze for DeltaItem<V, Attr>
impl<V, Attr> RefUnwindSafe for DeltaItem<V, Attr>where
Attr: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, Attr> Send for DeltaItem<V, Attr>
impl<V, Attr> Sync for DeltaItem<V, Attr>
impl<V, Attr> Unpin for DeltaItem<V, Attr>
impl<V, Attr> UnwindSafe for DeltaItem<V, Attr>where
Attr: UnwindSafe,
V: UnwindSafe,
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more