Struct algae_rs::mapping::MonoidOperation
source · pub struct MonoidOperation<'a, T> { /* private fields */ }
Expand description
A function wrapper enforcing identity existence and associativity.
Examples
use algae_rs::mapping::{MonoidOperation, BinaryOperation};
let mut mul = MonoidOperation::new(&|a, b| a * b, 1);
let six = mul.with(2, 3);
assert!(six.is_ok());
assert!(six.unwrap() == 6);
let mut add = MonoidOperation::new(&|a, b| a + b, 3);
let sum = add.with(4, 2);
assert!(sum.is_err());
Implementations§
Trait Implementations§
source§impl<'a, T: Copy + PartialEq> BinaryOperation<T> for MonoidOperation<'a, T>
impl<'a, T: Copy + PartialEq> BinaryOperation<T> for MonoidOperation<'a, T>
source§fn operation(&self) -> &dyn Fn(T, T) -> T
fn operation(&self) -> &dyn Fn(T, T) -> T
Returns a reference to the function underlying the operation
source§fn properties(&self) -> Vec<PropertyType<T>>
fn properties(&self) -> Vec<PropertyType<T>>
Vec of all enforced properties
source§fn input_history(&self) -> &Vec<T>
fn input_history(&self) -> &Vec<T>
Returns a reference to a Vec of all previous inputs to the operation
source§fn is(&self, property: PropertyType<T>) -> bool
fn is(&self, property: PropertyType<T>) -> bool
Returns whether or not
property
is enforced by the given operation