1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::ObjDirection;
use alloc::boxed::Box;
use mop_common::TraitCfg;
pub trait Obj<OR, S>: TraitCfg {
fn obj_direction(&self) -> ObjDirection;
fn result(&self, solution: &S) -> OR;
}
impl<O, OR, S> Obj<OR, S> for &'_ O
where
O: Obj<OR, S> + ?Sized,
{
fn obj_direction(&self) -> ObjDirection {
(*self).obj_direction()
}
fn result(&self, solution: &S) -> OR {
(*self).result(solution)
}
}
impl<O, OR, S> Obj<OR, S> for Box<O>
where
O: Obj<OR, S>,
{
fn obj_direction(&self) -> ObjDirection {
self.as_ref().obj_direction()
}
fn result(&self, solution: &S) -> OR {
self.as_ref().result(solution)
}
}
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)
}
}