mirror of
https://github.com/hannobraun/Fornjot
synced 2025-10-08 17:08:19 +00:00
commit
2c7c406aea
@ -35,10 +35,7 @@ impl<T> ObjectSet<T> {
|
|||||||
let mut added = BTreeSet::new();
|
let mut added = BTreeSet::new();
|
||||||
let mut inner = Vec::new();
|
let mut inner = Vec::new();
|
||||||
|
|
||||||
// TASK: Inline.
|
for handle in handles.into_iter() {
|
||||||
let handles = handles.into_iter();
|
|
||||||
|
|
||||||
for handle in handles {
|
|
||||||
if added.contains(&handle) {
|
if added.contains(&handle) {
|
||||||
panic!(
|
panic!(
|
||||||
"Constructing `ObjectSet` with duplicate handle: {:?}",
|
"Constructing `ObjectSet` with duplicate handle: {:?}",
|
||||||
@ -124,9 +121,17 @@ impl<T> ObjectSet<T> {
|
|||||||
self.inner.iter().position(|h| h.id() == handle.id())
|
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<T>) -> Option<&Handle<T>> {
|
||||||
|
self.index_of(handle)
|
||||||
|
.map(|index| self.nth_circular(index + self.len() - 1))
|
||||||
|
}
|
||||||
|
|
||||||
/// Access the item after the provided one
|
/// 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<T>) -> Option<&Handle<T>> {
|
pub fn after(&self, handle: &Handle<T>) -> Option<&Handle<T>> {
|
||||||
self.index_of(handle)
|
self.index_of(handle)
|
||||||
.map(|index| self.nth_circular(index + 1))
|
.map(|index| self.nth_circular(index + 1))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user