[][src]Trait tallystick::Numeric

pub trait Numeric {
    fn floor(self) -> Self;
fn fraction() -> bool;
fn max_value() -> Self; }

A trait for numeric types used to count votes.

Generally seen as the generic C in this codebase, this type should be automatically implemented for all numeric types you wish to use. It is used to provide trait specialization so differnetial logic can applied to integer or fractional (float) based vote counting.

You should pobably not implement this trait. If you have a numeric type that does not implement Numeric, you should instead implement num_traits::Num (and optionally num_traits::real::Real for types that support fractions.)

Required methods

fn floor(self) -> Self

Get the floor for this numeric type. For non-fractional types, this just returns self.

fn fraction() -> bool

Does this numeric type support fractional values? Integer-based types will return false. Float, or num_rational::Ratio based types should return true.

fn max_value() -> Self

Get max upper bound for this numeric type If this type has no upper bound, return zero

Loading content...

Implementors

impl<T: Num> Numeric for T[src]

impl<T: Num + Real> Numeric for T[src]

Loading content...