diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-17 17:09:19 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-17 17:09:19 +0100 |
| commit | 89f2e71852e96062ea9b756bf92fbf4e894871b1 (patch) | |
| tree | 836099ebd17adf30a24fc62464dfdd3d9c248480 /src/geom/spec.rs | |
| parent | 9a800daa82833c57eee04e92c701ca9a05a67d3b (diff) | |
Align node
Diffstat (limited to 'src/geom/spec.rs')
| -rw-r--r-- | src/geom/spec.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/geom/spec.rs b/src/geom/spec.rs index 4d631399..3b49b54a 100644 --- a/src/geom/spec.rs +++ b/src/geom/spec.rs @@ -23,6 +23,11 @@ impl<T> Spec<T> { Self { x: v.clone(), y: v } } + /// Borrows the individual fields. + pub fn as_ref(&self) -> Spec<&T> { + Spec { x: &self.x, y: &self.y } + } + /// Maps the individual fields with `f`. pub fn map<F, U>(self, mut f: F) -> Spec<U> where @@ -40,6 +45,14 @@ impl<T> Spec<T> { } } + /// Whether a condition is true for at least one of fields. + pub fn any<F>(self, mut f: F) -> bool + where + F: FnMut(&T) -> bool, + { + f(&self.x) || f(&self.y) + } + /// Whether a condition is true for both fields. pub fn all<F>(self, mut f: F) -> bool where |
