Struct algae_rs::mapping::InvertibleOperation
source · pub struct InvertibleOperation<'a, T> { /* private fields */ }Expand description
Examples
use algae_rs::mapping::{InvertibleOperation, BinaryOperation};
let mut add = InvertibleOperation::new(&|a, b| a + b, &|a, b| a - b, 0);
let seven = add.with(4, 3);
assert!(seven.is_ok());
assert!(seven.unwrap() == 7);
let mut bad_add = InvertibleOperation::new(&|a, b| a + b, &|a, b| a * b, 0);
let sum = bad_add.with(4, 2);
assert!(sum.is_err());Implementations§
Trait Implementations§
source§impl<'a, T: Copy + PartialEq> BinaryOperation<T> for InvertibleOperation<'a, T>
impl<'a, T: Copy + PartialEq> BinaryOperation<T> for InvertibleOperation<'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