Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply suggested cleanup from #2253 #2255

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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