Trait Number

Source
pub trait Number<V>
where V: Clone + Eq + Hash,
{ // Required methods fn new(numberer: Numberer<V>) -> Self; fn len(&self) -> usize; fn number(&self, value: V) -> Option<usize>; fn value(&self, number: usize) -> Option<V>; }
Expand description

Number a categorical variable.

Required Methods§

Source

fn new(numberer: Numberer<V>) -> Self

Construct a numberer for categorical variables.

Source

fn len(&self) -> usize

Get the number of possible values in the categorical variable.

This includes reserved numerical representations that do not correspond to values in the categorial variable.

Source

fn number(&self, value: V) -> Option<usize>

Get the number of a value from a categorical variable.

Mutable implementations of this trait must add the value if it is unknown and always return Option::Some.

Source

fn value(&self, number: usize) -> Option<V>

Get the value corresponding of a number.

Returns Option::None if the number is unknown or a reserved number.

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.

Implementors§

Source§

impl<V> Number<V> for ImmutableNumberer<V>
where V: Clone + Eq + Hash,

Source§

impl<V> Number<V> for MutableNumberer<V>
where V: Clone + Eq + Hash,