summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-09-14 12:27:21 +0200
committerLaurenz <laurmaedje@gmail.com>2021-09-14 12:27:21 +0200
commit87e776fcebd40cb9628124c19e7e9190b1bd24a5 (patch)
tree3276e39130dc112a11c2594a3b470687e91a1a36 /src/util
parent18190f377a556ae5d5bb855044a95ecea071432f (diff)
Add `BoolExt` trait with `flip` method
Diffstat (limited to 'src/util')
-rw-r--r--src/util/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/mod.rs b/src/util/mod.rs
index 3608ca76..1abdcbc9 100644
--- a/src/util/mod.rs
+++ b/src/util/mod.rs
@@ -11,6 +11,18 @@ use std::cmp::Ordering;
use std::ops::Range;
use std::path::{Component, Path, PathBuf};
+/// Additional methods for booleans.
+pub trait BoolExt {
+ /// Toggle the value of the bool in place.
+ fn flip(&mut self);
+}
+
+impl BoolExt for bool {
+ fn flip(&mut self) {
+ *self = !*self;
+ }
+}
+
/// Additional methods for options.
pub trait OptionExt<T> {
/// Replace `self` with `other` if `self` is `Some`.