Trait rle::SplitableSpan[][src]

pub trait SplitableSpan: Clone {
    fn len(&self) -> usize;
fn truncate(&mut self, at: usize) -> Self;
fn can_append(&self, other: &Self) -> bool;
fn append(&mut self, other: Self); fn truncate_keeping_right(&mut self, at: usize) -> Self { ... }
fn prepend(&mut self, other: Self) { ... } }
Expand description

An entry is expected to contain multiple items.

A SplitableSpan is a range entry. That is, an entry which contains a compact run of many entries internally.

Required methods

The number of child items in the entry. This is indexed with the size used in truncate.

Split the entry, returning the part of the entry which was jettisoned. After truncating at pos, self.len() == pos and the returned value contains the rest of the items.

let initial_len = entry.len();
let rest = entry.truncate(truncate_at);
assert!(initial_len == truncate_at + rest.len());

at parameter must strictly obey 0 < at < entry.len()

See if the other item can be appended to self. can_append will always be called immediately before append.

Merge the passed item into self. Essentially, self = self + other.

The other item must be a valid target for merging (as per can_append(), above).

Provided methods

The inverse of truncate. This method mutably truncates an item, keeping all content from at..item.len() and returning the item range from 0..at.

Append an item at the start of this item. self = other + self.

This item must be a valid append target for other. That is, other.can_append(self) must be true for this method to be called.

Implementors