Trait Leaf
pub trait Leaf:
Sized
+ Clone
+ Default {
// Required methods
fn len(&self) -> usize;
fn is_ok_child(&self) -> bool;
fn push_maybe_split(&mut self, other: &Self, iv: Interval) -> Option<Self>;
// Provided method
fn subseq(&self, iv: Interval) -> Self { ... }
}Expand description
A trait for the leaves of trees of type Node.
Two leafs can be concatenated using push_maybe_split.
Required Methods§
fn len(&self) -> usize
fn len(&self) -> usize
Measurement of leaf in base units. A ‘base unit’ refers to the smallest discrete unit by which a given concrete type can be indexed. Concretely, for Rust’s String type the base unit is the byte.
fn is_ok_child(&self) -> bool
fn is_ok_child(&self) -> bool
Generally a minimum size requirement for leaves.
fn push_maybe_split(&mut self, other: &Self, iv: Interval) -> Option<Self>
fn push_maybe_split(&mut self, other: &Self, iv: Interval) -> Option<Self>
Combine the part other denoted by the Interval iv into self,
optionly splitting off a new Leaf if self would have become too big.
Returns either None if no splitting was needed, or Some(rest) if
rest was split off.
Interval is in “base units”. Generally implements a maximum size.
§Invariants:
- If one or the other input is empty, then no split.
- If either input satisfies
is_ok_child, then, on return,selfsatisfies this, as does the optional split.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.