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()
fn can_append(&self, other: &Self) -> bool
fn can_append(&self, other: &Self) -> bool
See if the other item can be appended to self. can_append will always be called
immediately before append.
Provided methods
fn truncate_keeping_right(&mut self, at: usize) -> Self
fn truncate_keeping_right(&mut self, at: usize) -> Self
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.