1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use crate::ObjDirection; /// Objective /// /// # Types /// /// * `OR`: Objective Result /// * `S`: Solution pub trait Obj<OR, S> { fn obj_direction(&self) -> ObjDirection; fn result(&self, solution: &S) -> OR; } impl<OR, S> Obj<OR, S> for (ObjDirection, fn(&S) -> OR) { fn obj_direction(&self) -> ObjDirection { self.0 } fn result(&self, solution: &S) -> OR { (self.1)(solution) } }