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
use ;
/** Fork a [`State`] into zero or more alternate states.
Added to a [`State`] with [`.fork()`](State::fork()).
# Example:
```
use canrun::{Fork, Query, State, StateIter, Value};
use std::rc::Rc;
struct Is1or2 {
x: Value<i32>,
}
impl Fork for Is1or2 {
fn fork(&self, state: &State) -> StateIter {
let s1 = state.clone().unify(&self.x, &Value::new(1));
let s2 = state.clone().unify(&self.x, &Value::new(2));
Box::new(s1.into_iter().chain(s2.into_iter()))
}
}
# fn main() {
let x = Value::var();
let state = State::new();
let state = state.fork(Is1or2 { x: x.clone() });
let results: Vec<_> = state.query(x).collect();
assert_eq!(results, vec![1, 2]);
# }
```
*/