From 26cc863e06957781863bc35437dac0648b5078f4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 28 Jun 2024 18:00:28 +0200 Subject: [PATCH 1/3] Inline redundant variable --- crates/fj-core/src/topology/object_set.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/fj-core/src/topology/object_set.rs b/crates/fj-core/src/topology/object_set.rs index c8fde80b2..18ea096e7 100644 --- a/crates/fj-core/src/topology/object_set.rs +++ b/crates/fj-core/src/topology/object_set.rs @@ -35,10 +35,7 @@ impl ObjectSet { let mut added = BTreeSet::new(); let mut inner = Vec::new(); - // TASK: Inline. - let handles = handles.into_iter(); - - for handle in handles { + for handle in handles.into_iter() { if added.contains(&handle) { panic!( "Constructing `ObjectSet` with duplicate handle: {:?}", From 7bccd673942e5aadb7e0a38a4d02cd1a2e797f7d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 28 Jun 2024 18:00:47 +0200 Subject: [PATCH 2/3] Fix word in doc comment --- crates/fj-core/src/topology/object_set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-core/src/topology/object_set.rs b/crates/fj-core/src/topology/object_set.rs index 18ea096e7..c2be436e9 100644 --- a/crates/fj-core/src/topology/object_set.rs +++ b/crates/fj-core/src/topology/object_set.rs @@ -123,7 +123,7 @@ impl ObjectSet { /// Access the item after the provided one /// - /// Returns `None`, if the provided item is not in this iterator. + /// Returns `None`, if the provided item is not in this set. pub fn after(&self, handle: &Handle) -> Option<&Handle> { self.index_of(handle) .map(|index| self.nth_circular(index + 1)) From 80828e28cbfb5305843064373a48b873dbf5eb9f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 28 Jun 2024 18:00:56 +0200 Subject: [PATCH 3/3] Add `ObjectSet::before` --- crates/fj-core/src/topology/object_set.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/fj-core/src/topology/object_set.rs b/crates/fj-core/src/topology/object_set.rs index c2be436e9..1a34751b2 100644 --- a/crates/fj-core/src/topology/object_set.rs +++ b/crates/fj-core/src/topology/object_set.rs @@ -121,6 +121,14 @@ impl ObjectSet { self.inner.iter().position(|h| h.id() == handle.id()) } + /// Access the item before the provided one + /// + /// Returns `None`, if the provided item is not in this set. + pub fn before(&self, handle: &Handle) -> Option<&Handle> { + self.index_of(handle) + .map(|index| self.nth_circular(index + self.len() - 1)) + } + /// Access the item after the provided one /// /// Returns `None`, if the provided item is not in this set.