-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlib.rs
More file actions
52 lines (44 loc) · 1.21 KB
/
lib.rs
File metadata and controls
52 lines (44 loc) · 1.21 KB
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
52
use struct_patch::Catalyst;
use substrate::Base;
#[derive(Default, Catalyst)]
#[catalyst(bind = Base)]
#[allow(dead_code)]
struct Amyloid {
pub extra_bool: bool,
pub extra_string: String,
pub extra_option: Option<usize>,
}
#[derive(Catalyst)]
#[catalyst(bind = Base)]
#[complex(name = "SmallCpx")]
#[allow(dead_code)]
#[complex(attribute(derive(Default)))]
struct SmallAmyloid {
pub extra_bool: bool,
}
#[allow(dead_code)]
impl SmallCpx {
/// A reaction to change the substrate
pub fn reaction(&mut self) {
self.field_bool = true;
}
}
#[cfg(test)]
mod tests {
use super::*;
use struct_patch::Complex;
#[test]
fn complex_works() {
let mut small_complex = SmallCpx::default();
assert_eq!(small_complex.field_bool, false);
assert_eq!(small_complex.field_string, String::new());
assert_eq!(small_complex.field_option, None);
assert_eq!(small_complex.extra_bool, false);
small_complex.reaction();
let (_cat, substrate) = small_complex.decouple();
assert!(substrate.has_bool());
let amyloid = Amyloid::default();
let complex = amyloid.bind(substrate);
assert_eq!(complex.field_bool, true);
}
}