Implement IntoIterator for IMap and IArray via self-reference#69
Conversation
|
looks at PR number Nice. |
|
I prefer this approach because the end result is more usable for the end user. It might use unsafe internally in the ouroboros dependency but not in here and the code is perfectly safe right? Even std uses unsafe so I don't see the problem. The only thing that bothers me is all the complexity introduced seems to be mostly related to handling IMap which I'm not sure is any useful at all. I've used implicit clone with yew for so long and never ever cared about IMap honestly. Do you know if it's used anywhere? |
I believe macros generate code with
It's used in my own code, same for #58. As for Yew, I believe |
This PR is a variant of implementing
IntoIteratorvia self-reference to the respective collections (IArray,IMap).These implementations are done with the help of the ouroboros crate. This means it uses
unsafe(in the macro-generated code, I believe) to achieve self-reference. This may be undesired if fully safe code is wanted.From an API point, this solution seems ideal - any struct will be taken by ownership and allows for these
IntoIterstructs to outlive scope they are made in.The
IArrayimplementation is rewritten to the same approach for consistency. No breaking changes.Closes #68 because the two approaches are disjoint.