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

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.

Measure the weight of Node by this metric.

Convert the Metric into a byte index into the given Node

Returns

  • Some with the byte index of the beginning of the nth element in node measured by this Metric, if there is an nth element
  • None if there is no nth element in node

Implementations on Foreign Types

impl Measured<Grapheme> for str
[src]

[src]

Convert the Metric into a byte index into the given Node

Returns

  • Some with the byte index of the beginning of the nth element in node measured by this Metric, if there is an nth element
  • None if there is no nth element in node

[src]

[src]

impl Measured<Grapheme> for String
[src]

[src]

[src]

[src]

impl Measured<Line> for str
[src]

[src]

[src]

[src]

impl Measured<Line> for String
[src]

[src]

[src]

[src]

impl Measured<usize> for str
[src]

[src]

[src]

[src]

impl Measured<usize> for String
[src]

[src]

[src]

[src]

Implementors