Skip to main content

Normalizable

Trait Normalizable 

Source
pub trait Normalizable<T> {
    // Required method
    fn normalize(&self, targeted_sum: T) -> Result<Vec<T>, &'static str>;
}
Expand description

A collection-like object that is made of values of type T and can normalize its individual values around a centric point.

Note that the order of items in the collection may affect the result.

Required Methods§

Source

fn normalize(&self, targeted_sum: T) -> Result<Vec<T>, &'static str>

Normalize self around targeted_sum.

Only returns Ok if the new sum of results is guaranteed to be equal to targeted_sum. Else, returns an error explaining why it failed to do so.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Normalizable<u8> for Vec<u8>

Source§

fn normalize(&self, targeted_sum: u8) -> Result<Vec<u8>, &'static str>

Source§

impl Normalizable<u16> for Vec<u16>

Source§

fn normalize(&self, targeted_sum: u16) -> Result<Vec<u16>, &'static str>

Source§

impl Normalizable<u32> for Vec<u32>

Source§

fn normalize(&self, targeted_sum: u32) -> Result<Vec<u32>, &'static str>

Source§

impl Normalizable<u64> for Vec<u64>

Source§

fn normalize(&self, targeted_sum: u64) -> Result<Vec<u64>, &'static str>

Source§

impl Normalizable<u128> for Vec<u128>

Source§

fn normalize(&self, targeted_sum: u128) -> Result<Vec<u128>, &'static str>

Source§

impl<P: PerThing> Normalizable<P> for Vec<P>

Source§

fn normalize(&self, targeted_sum: P) -> Result<Vec<P>, &'static str>

Implementors§