Trait UnitConverter
pub trait UnitConverter<N, U>where
N: NodeInfo,{
// Required methods
fn count(l: &<N as NodeInfo>::L, in_measured_units: U) -> usize;
fn measure(l: &<N as NodeInfo>::L, in_base_units: usize) -> U;
fn base(l: &N) -> usize;
fn node_measured(l: &N) -> U;
fn count_affinty() -> UnitAffinity;
fn measure_affinty() -> UnitAffinity;
}Expand description
A trait for NodeInfo to convert between base units and measured units for example, for a Rope, the base unit can be the bytes and the measured units can be line number The base unit is usize and measured units is a generic type
Required Methods§
fn count(l: &<N as NodeInfo>::L, in_measured_units: U) -> usize
fn count(l: &<N as NodeInfo>::L, in_measured_units: U) -> usize
Given the measured units, how many base units are there in this NodeInfo
fn measure(l: &<N as NodeInfo>::L, in_base_units: usize) -> U
fn measure(l: &<N as NodeInfo>::L, in_base_units: usize) -> U
Measure the NodeInfo given the base units
fn node_measured(l: &N) -> U
fn node_measured(l: &N) -> U
The measured units in this NodeInfo
fn count_affinty() -> UnitAffinity
fn count_affinty() -> UnitAffinity
Return The UnitAffinity of the converter when doing count when the unit is at the edge of two nodes For UnitAffinity::Before, it will use the node before For UnitAffinity::After, it will use the node after
fn measure_affinty() -> UnitAffinity
fn measure_affinty() -> UnitAffinity
Return The UnitAffinity of the converter when doing measure when the unit is at the edge of two nodes For UnitAffinity::Before, it will use the node before For UnitAffinity::After, it will use the node after
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".