From 28b2377eb83adb2dc3beab538cfb46feb789babf Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 8 Nov 2022 12:12:57 +0100 Subject: [PATCH] Use concrete type as return value I'm currently writing some code that requires more from that type than just `Iterator`. Using a concrete type seems more practical than specifying all kinds of additional bounds. --- crates/fj-kernel/src/objects/cycle.rs | 9 ++++++++- crates/fj-kernel/src/objects/mod.rs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/objects/cycle.rs b/crates/fj-kernel/src/objects/cycle.rs index 518064a22..7a5e12769 100644 --- a/crates/fj-kernel/src/objects/cycle.rs +++ b/crates/fj-kernel/src/objects/cycle.rs @@ -1,3 +1,5 @@ +use std::slice; + use fj_interop::ext::SliceExt; use fj_math::{Scalar, Winding}; use pretty_assertions::assert_eq; @@ -76,7 +78,7 @@ impl Cycle { } /// Access the half-edges that make up the cycle - pub fn half_edges(&self) -> impl Iterator> + '_ { + pub fn half_edges(&self) -> HalfEdgesOfCycle { self.half_edges.iter() } @@ -138,3 +140,8 @@ impl Cycle { unreachable!("Encountered invalid cycle: {self:#?}"); } } + +/// An iterator over the half-edges of a [`Cycle`] +/// +/// Returned by [`Cycle::half_edges`]. +pub type HalfEdgesOfCycle<'a> = slice::Iter<'a, Handle>; diff --git a/crates/fj-kernel/src/objects/mod.rs b/crates/fj-kernel/src/objects/mod.rs index bdba01e72..07a37bd53 100644 --- a/crates/fj-kernel/src/objects/mod.rs +++ b/crates/fj-kernel/src/objects/mod.rs @@ -85,7 +85,7 @@ mod vertex; pub use self::{ curve::{Curve, GlobalCurve}, - cycle::Cycle, + cycle::{Cycle, HalfEdgesOfCycle}, edge::{GlobalEdge, HalfEdge, VerticesInNormalizedOrder}, face::{Face, FaceSet, Handedness}, shell::Shell,