Trait an_rope::metric::Measured
[−]
[src]
pub trait Measured<M: Metric> { fn measure(&self) -> M; fn measure_weight(&self) -> M; fn to_byte_index(&self, index: M) -> Option<usize>; }
Trait indicating that a type may be measured with Metric
M.
Required Methods
fn measure(&self) -> M
Apply Metric
to Self
Although we aren't currently enforcing this, measure
ing a Node
with
two children should produce the same result as measure
ing both
children and Monoid::sum
ming the result. That is to say, measure
should be a monoid homomorphism.
fn measure_weight(&self) -> M
Measure the weight
of Node
by this metric
.
fn to_byte_index(&self, index: M) -> Option<usize>
Convert the Metric
into a byte index into the given Node
Returns
Some
with the byte index of the beginning of then
th element innode
measured by thisMetric
, if there is ann
th elementNone
if there is non
th element innode