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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#[derive(Copy, Clone, Debug)]
pub struct InputOptions {
pub(super) help: bool,
pub(super) movement: bool,
pub(super) resize: bool,
pub(super) undo_redo: bool,
}
impl InputOptions {
#[inline]
#[must_use]
pub const fn new() -> Self {
Self {
help: false,
movement: false,
resize: true,
undo_redo: false,
}
}
#[inline]
#[must_use]
pub const fn help(mut self, val: bool) -> Self {
self.help = val;
self
}
#[inline]
#[must_use]
pub const fn movement(mut self, val: bool) -> Self {
self.movement = val;
self
}
#[inline]
#[must_use]
pub const fn resize(mut self, val: bool) -> Self {
self.resize = val;
self
}
#[inline]
#[must_use]
pub const fn undo_redo(mut self, val: bool) -> Self {
self.undo_redo = val;
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn new_default() {
let options = InputOptions::new();
assert!(!options.help);
assert!(!options.movement);
assert!(options.resize);
assert!(!options.undo_redo);
}
#[test]
fn help() {
let options = InputOptions::new().help(true);
assert!(options.help);
}
#[test]
fn movement() {
let options = InputOptions::new().movement(true);
assert!(options.movement);
}
#[test]
fn resize() {
let options = InputOptions::new().resize(false);
assert!(!options.resize);
}
#[test]
fn undo_redo() {
let options = InputOptions::new().undo_redo(true);
assert!(options.undo_redo);
}
}