Struct emergent::consideration::ClosureConsideration
source · pub struct ClosureConsideration<M = ()>(pub Box<dyn Fn(&M) -> Scalar + Send + Sync>);
Expand description
Consideration that wraps a closure.
Example
use emergent::prelude::*;
struct Memory { counter: usize }
let mut memory = Memory { counter: 10 };
let consideration = ClosureConsideration::new(
|memory: &Memory| 1.0 / memory.counter as Scalar,
);
assert_eq!(consideration.score(&memory), 0.1);
Tuple Fields§
§0: Box<dyn Fn(&M) -> Scalar + Send + Sync>
Implementations§
Trait Implementations§
source§impl<M> Consideration<M> for ClosureConsideration<M>
impl<M> Consideration<M> for ClosureConsideration<M>
Auto Trait Implementations§
impl<M = ()> !RefUnwindSafe for ClosureConsideration<M>
impl<M> Send for ClosureConsideration<M>
impl<M> Sync for ClosureConsideration<M>
impl<M> Unpin for ClosureConsideration<M>
impl<M = ()> !UnwindSafe for ClosureConsideration<M>
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