pub struct GroupOperation<'a, T> { /* private fields */ }
Expand description
A function wrapper enforcing identity existence, invertibility, and associativity.
§Examples
use algae_rs::mapping::{GroupOperation, BinaryOperation};
let mut add = GroupOperation::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 = GroupOperation::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 GroupOperation<'a, T>
impl<'a, T: Copy + PartialEq> BinaryOperation<T> for GroupOperation<'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 operationAuto Trait Implementations§
impl<'a, T> Freeze for GroupOperation<'a, T>where
T: Freeze,
impl<'a, T> !RefUnwindSafe for GroupOperation<'a, T>
impl<'a, T> !Send for GroupOperation<'a, T>
impl<'a, T> !Sync for GroupOperation<'a, T>
impl<'a, T> Unpin for GroupOperation<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for GroupOperation<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more