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, measureing a Node with
two children should produce the same result as measureing both
children and Monoid::summing 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
Somewith the byte index of the beginning of thenth element innodemeasured by thisMetric, if there is annth elementNoneif there is nonth element innode
Implementations on Foreign Types
impl Measured<Grapheme> for str[src]
fn to_byte_index(&self, index: Grapheme) -> Option<usize>[src]
Convert the Metric into a byte index into the given Node
Returns
Somewith the byte index of the beginning of thenth element innodemeasured by thisMetric, if there is annth elementNoneif there is nonth element innode