Skip to content
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

Merged
merged 6 commits into from
May 15, 2020
Merged

Conversation

xStrom
Copy link
Member

@xStrom xStrom commented May 15, 2020

This PR adds im::Vector support for the List widget when the im feature is enabled. It seems to work real nicely with ListIter<T> where we can just pass references. The shared data ListIter<(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 than Arc<Vec>. I also updated the list example to use Vector. 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 of Vec<T: Data> as discussed in #911. The implementation was broken as well.

@xStrom xStrom added widget concerns a particular widget S-needs-review waits for review labels May 15, 2020
Copy link
Collaborator

@luleyleo luleyleo left a 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!

}

#[cfg(feature = "im")]
impl<T1: Data, T: Data> ListIter<(T1, T)> for (T1, Vector<T>) {
Copy link
Collaborator

@luleyleo luleyleo May 15, 2020

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. 😉

Copy link
Member Author

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.

Copy link
Collaborator

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.

@xStrom xStrom merged commit 57a0c35 into linebender:master May 15, 2020
@xStrom xStrom deleted the im-data branch May 15, 2020 13:43
@xStrom xStrom removed the S-needs-review waits for review label May 15, 2020
@cmyr
Copy link
Member

cmyr commented May 17, 2020

Something to reiterate: the current List widget is a proof of concept, and may need to be reconsidered or otherwise rearchitected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
widget concerns a particular widget
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants