Update with arbitrary containers of Handles or HandleWrappers #2253
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main purpose of this PR was to make it easier to check for duplicate handles referencing the same object, however it comes with a useful side effect.
I personally needed this because my CAD program accepts a scripting language to generate models with. The number of changes a user may make is dynamic, so I need the option to provide a variable number of new faces when updating a shell. I also need to validate that the new list of faces does not contain any duplicate handles so that I can avoid a panic and produce a more meaningful error message for the user.
The key change is that
ObjectSet::new
andObjectSet::replace
no longer take just arrays of Handles, but instead they take any iterable object that produces objects that can be turned into HandleWrapper.This provides two key features:
With such a workflow, things like this are now easy to implement:
I think at this point it might be good to rename
HandleWrapper
toObjectReference
to imply that we are comparing the references and not the objects, but I'll let you make that call. Coming up with a name that reflects the purpose of that thing is... difficult.