euv_ui/hook/use_boolean/impl.rs
1use super::*;
2
3/// Inherent implementation of [`UseBoolean`].
4impl UseBoolean {
5 /// Sets the value to `true`.
6 pub fn set_true(&self) {
7 self.get_value().set(true);
8 }
9
10 /// Sets the value to `false`.
11 pub fn set_false(&self) {
12 self.get_value().set(false);
13 }
14
15 /// Flips the value: `true` becomes `false`, `false` becomes `true`.
16 pub fn toggle(&self) {
17 let current: bool = self.get_value().get();
18 self.get_value().set(!current);
19 }
20
21 /// Replaces the value with `next`.
22 ///
23 /// # Arguments
24 ///
25 /// - `bool` - The new value.
26 pub fn set_value(&self, next: bool) {
27 self.get_value().set(next);
28 }
29
30 /// Returns the current value as a snapshot.
31 ///
32 /// # Returns
33 ///
34 /// - `bool` - The current value.
35 pub fn get(&self) -> bool {
36 self.get_value().get()
37 }
38}