Skip to content

Commit

Permalink
Merge pull request #2255 from IamTheCarl/main
Browse files Browse the repository at this point in the history
Apply suggested cleanup from #2253
  • Loading branch information
hannobraun authored Mar 7, 2024
2 parents b1798e3 + 45b5814 commit 622b1ee
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions crates/fj-core/src/objects/object_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ impl<T> ObjectSet<T> {
/// # Panics
///
/// Panics, if the iterator contains duplicate `Handle`s.
pub fn new<H>(handles: impl IntoIterator<Item = H>) -> Self
pub fn new(
handles: impl IntoIterator<Item = impl Into<HandleWrapper<T>>>,
) -> Self
where
T: Debug + Ord,
H: Into<HandleWrapper<T>>,
{
let mut added = BTreeSet::new();
let mut inner = Vec::new();
Expand Down Expand Up @@ -150,14 +151,13 @@ impl<T> ObjectSet<T> {
///
/// Panics, if the update results in a duplicate item.
#[must_use]
pub fn replace<H>(
pub fn replace(
&self,
original: &Handle<T>,
replacements: impl IntoIterator<Item = H>,
replacements: impl IntoIterator<Item = impl Into<Handle<T>>>,
) -> Option<Self>
where
T: Debug + Ord,
H: Into<Handle<T>>,
{
let mut iter = self.iter().cloned().peekable();

Expand Down Expand Up @@ -268,18 +268,6 @@ mod tests {
// shouldn't do that in this case.
}

#[test]
fn deduplicate_with_hashset() {
let mut core = Core::new();

let bare_cycle = Cycle::new([]);
let cycle = bare_cycle.insert(&mut core);

let standard_set = HashSet::from([cycle.clone(), cycle.clone()]);

assert_eq!(standard_set, [cycle].into());
}

#[test]
fn object_set_from_handle_wrappers() {
let mut core = Core::new();
Expand Down

0 comments on commit 622b1ee

Please sign in to comment.