-
Notifications
You must be signed in to change notification settings - Fork 567
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
Add im::Vector support to the List widget. #940
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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::Vector
support for theList
widget when theim
feature 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
Vector
usage seems much more ergonomical thanArc<Vec>
. I also updated thelist
example 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
Data
implementation ofVec<T: Data>
as discussed in #911. The implementation was broken as well.