chiark
/
gitweb
/
~ianmdlvl
/
otter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
eef0100
)
Provide PosC::try_map
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sat, 27 Feb 2021 11:18:53 +0000
(11:18 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sat, 27 Feb 2021 11:49:54 +0000
(11:49 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/spec.rs
patch
|
blob
|
history
diff --git
a/src/spec.rs
b/src/spec.rs
index 5efe3f7070e2ea9427b917a851c422fa8bfb0aae..89f3e18ddb185fd3f28512ca84235588eb91be29 100644
(file)
--- a/
src/spec.rs
+++ b/
src/spec.rs
@@
-309,6
+309,16
@@
pub mod pos_traits {
}
}
+ impl<T:Copy+Clone+Debug> PosC<T> {
+ pub fn try_map<E:Debug, U:Copy+Clone+Debug, F: FnMut(T) -> Result<U,E>>
+ (self, f: F) -> Result<PosC<U>,E>
+ {
+ PosC::try_from_iter_2(
+ self.0.iter().cloned().map(f)
+ )
+ }
+ }
+
impl PosC<Coord> {
pub fn promote(&self) -> PosC<f64> { self.map(|v| v as f64) }
}