Add im::Vector support to the List widget.#940
Conversation
luleyleo
left a comment
There was a problem hiding this comment.
Yes, the cloning is not great but should be ok if all Data types are actually cheap to clone (looking at you String). I got a nit pick regarding the generic naming, but otherwise it looks great.
Thanks for implementing this!
druid/src/widget/list.rs
Outdated
| } | ||
|
|
||
| #[cfg(feature = "im")] | ||
| impl<T1: Data, T: Data> ListIter<(T1, T)> for (T1, Vector<T>) { |
There was a problem hiding this comment.
Maybe call them Shared and T instead? Or at least S and T.
I still do not understand why people like useless names for generic parameters,
this is really not something where we should let mathematicians inspire us. 😉
There was a problem hiding this comment.
I just copied that from the Arc<Vec> implementation, but yeah it took me a while to grasp what the T1 even is, because I hadn't used List before. I changed it to S and added a comment.
There was a problem hiding this comment.
Thanks! At first I got it the wrong way, thought T1 would be the iterable due to the 1.
|
Something to reiterate: the current |
This PR adds
im::Vectorsupport for theListwidget when theimfeature is enabled. It seems to work real nicely withListIter<T>where we can just pass references. The shared dataListIter<(T1, T)>implementation is less nice as we still need to clone data due to the signature. It may be worth looking into changing the signature for shared data lists in the future so that we could use just references even with shared data.The
Vectorusage seems much more ergonomical thanArc<Vec>. I also updated thelistexample to useVector. The real functional diff to the example looks great, with basically just removing code. However due to having to add feature guards the code diff looks a lot noisier.I also removed an unnecessary variable from the
Arc<Vec>implementation, which was the remnant of a previous refactoring.This PR also reverts the
Dataimplementation ofVec<T: Data>as discussed in #911. The implementation was broken as well.