--- a/rust/integral-geometry/src/lib.rs Mon Nov 05 19:56:28 2018 +0300
+++ b/rust/integral-geometry/src/lib.rs Mon Nov 05 20:22:09 2018 +0300
@@ -464,11 +464,21 @@
(&self.vertices[..self.edges_count()]).iter()
}
- pub fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &mut Point> + 'a {
+ fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &mut Point> + 'a {
let edges_count = self.edges_count();
(&mut self.vertices[..edges_count]).iter_mut()
}
+ pub fn for_each<F>(&mut self, f: F)
+ where F: (Fn(&mut Point))
+ {
+ if !self.vertices.is_empty() {
+ self.iter_mut().for_each(f);
+ let edges_count = self.edges_count();
+ self.vertices[edges_count] = self.vertices[0]
+ }
+ }
+
pub fn iter_edges<'a>(&'a self) -> impl Iterator<Item = Line> + 'a {
(&self.vertices[0..self.edges_count()])
.iter()