-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Implement FromIterator/IntoIterator for dynamic types #14250
Implement FromIterator/IntoIterator for dynamic types #14250
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! I think these changes will be super useful!
@@ -508,6 +508,44 @@ impl Debug for DynamicStruct { | |||
} | |||
} | |||
|
|||
impl FromIterator<(String, Box<dyn Reflect>)> for DynamicStruct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are cool! I've been wanting a succinct way to create DynamicStruct
and friends for a long time haha
@SpecificProtagonist could you also update the title and description to account for your new changes? |
Yep – already updated the description; accidentally cancelled the edit to the title :3 Do you know what's going on with the compile error? It doesn't appear locally for me, and doesn't make any sense to me either: It says that the return type of |
Looks like For now, I'd recommend just doing: self.values.into_vec().into_iter() It might be a good idea also leaving a |
Thanks! Fixed it. Didn't leave a todo as the resulting code is fine. I've also removed the homogeneous |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple minor comments, but nothing worth blocking over. Good feature!
Objective
Implement FromIterator/IntoIterator for dynamic types where missing
Note:
IntoIterator
for&Array
& co because of orphan rulesinto_iter().collect()
is a no-op forVec
s because of specializationMigration Guide
DynamicArray::from_vec
toDynamicArray::from_iter