chiark / gitweb /
edges in other order
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Oct 2022 21:32:16 +0000 (22:32 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Oct 2022 21:32:16 +0000 (22:32 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/lib.rs

index daca1664462a131a3059560889908330e64a424f..1a1620511a37eab148b1f24f287ebc1b0fa37495 100644 (file)
@@ -5,7 +5,7 @@ pub use std::io;
 pub use std::io::Write as _;
 pub use std::iter;
 
-pub use itertools::izip;
+pub use itertools::{chain, izip};
 pub use itertools::Itertools;
 
 pub fn default<T: Default>() -> T { Default::default() }
@@ -43,10 +43,10 @@ pub fn shape_abut_zero(shape: &mut Shape) {
 pub fn shape_edges(shape: &Shape)
                    -> impl Iterator<Item=[Point; 2]> + Clone + '_
 {
-  shape
-    .iter()
-    .cycle()
-    .take(shape.len() + 1)
+  chain!(
+    shape.iter().rev().take(1),
+    shape,
+  )
     .tuple_windows()
     .map(|(&a,&b)| [a,b])
 }