Struct loro_delta::DeltaRope

source ·
pub struct DeltaRope<V: DeltaValue, Attr: DeltaAttr> { /* private fields */ }
Expand description

A DeltaRope is a rope-like data structure that can be used to represent a sequence of DeltaItem. It has efficient operations for composing other DeltaRopes. It can also be used as a rope, where it only contains insertions.

Implementations§

source§

impl<V: Debug + Clone, const C: usize, Attr: DeltaAttr> DeltaRope<ArrayVec<V, C>, Attr>

source

pub fn from_many(iter: impl Iterator<Item = V>) -> Self

source§

impl<V: DeltaValue, Attr: DeltaAttr> DeltaRope<V, Attr>

source

pub fn compose(&mut self, other: &Self)

source§

impl<V: DeltaValue, Attr: DeltaAttr> DeltaRope<V, Attr>

source

pub fn new() -> Self

source

pub fn first(&self) -> Option<&DeltaItem<V, Attr>>

source

pub fn iter(&self) -> impl Iterator<Item = &DeltaItem<V, Attr>>

source

pub fn len(&self) -> usize

Returns the length of the delta rope (insertions + retains).

source

pub fn old_len(&self) -> usize

Returns the length of the delta rope (deletions + retains).

source

pub fn is_empty(&self) -> bool

source

pub fn push_insert(&mut self, v: V, attr: Attr) -> &mut Self

source

pub fn push_retain(&mut self, retain: usize, attr: Attr) -> &mut Self

source

pub fn push_replace(&mut self, value: V, attr: Attr, delete: usize) -> &mut Self

source

pub fn push_delete(&mut self, len: usize) -> &mut Self

source

pub fn push(&mut self, item: DeltaItem<V, Attr>) -> &mut Self

source

pub fn iter_with_len(&self) -> Iter<'_, V, Attr>

Returns an iterator that can iterate over the delta rope with a custom length.

It’s more controllable compared to the default iterator.

  • Iterating over the delta rope with a custom length.
  • You can peek the next item.

It’s useful to implement algorithms related to Delta

source

pub fn chop(&mut self)

source§

impl<Attr: DeltaAttr> DeltaRope<TextChunk, Attr>

source

pub fn insert_str(&mut self, index: usize, s: &str)

source

pub fn push_str_insert(&mut self, s: &str) -> &mut Self

source

pub fn push_str_insert_with_attr(&mut self, s: &str, attr: Attr) -> &mut Self

source

pub fn try_to_string(&self) -> Option<String>

Trait Implementations§

source§

impl<V: Clone + DeltaValue, Attr: Clone + DeltaAttr> Clone for DeltaRope<V, Attr>

source§

fn clone(&self) -> DeltaRope<V, Attr>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V: DeltaValue, Attr: DeltaAttr> Debug for DeltaRope<V, Attr>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<V: DeltaValue + Debug, Attr: DeltaAttr + Debug> Default for DeltaRope<V, Attr>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<V: DeltaValue + PartialEq, Attr: DeltaAttr + PartialEq> PartialEq for DeltaRope<V, Attr>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<V, Attr> Freeze for DeltaRope<V, Attr>

§

impl<V, Attr> RefUnwindSafe for DeltaRope<V, Attr>
where Attr: RefUnwindSafe, V: RefUnwindSafe,

§

impl<V, Attr> Send for DeltaRope<V, Attr>
where Attr: Send, V: Send,

§

impl<V, Attr> Sync for DeltaRope<V, Attr>
where Attr: Sync, V: Sync,

§

impl<V, Attr> Unpin for DeltaRope<V, Attr>
where Attr: Unpin, V: Unpin,

§

impl<V, Attr> UnwindSafe for DeltaRope<V, Attr>
where Attr: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.