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

Deref, Index, and InArc lenses #367

Merged
merged 3 commits into from
Dec 3, 2019
Merged

Deref, Index, and InArc lenses #367

merged 3 commits into from
Dec 3, 2019

Conversation

Ralith
Copy link
Collaborator

@Ralith Ralith commented Dec 1, 2019

Builds on #344.

Note that this does not provide a way to index into an Arc<Vec<T>>. That's intentional, as any such operation would cause a deep copy in every Widget::event.

@Ralith Ralith changed the title Index Deref and Index lenses Dec 1, 2019
@Ralith Ralith force-pushed the index branch 3 times, most recently from edbc31b to 6bb1c41 Compare December 1, 2019 21:50
druid/src/lens.rs Outdated Show resolved Hide resolved
@Ralith Ralith force-pushed the index branch 4 times, most recently from 945ecb2 to df63e6f Compare December 1, 2019 22:18
@Ralith Ralith changed the title Deref and Index lenses Deref, Index, and MakeMut lenses Dec 2, 2019
@Ralith Ralith force-pushed the index branch 2 times, most recently from a811626 to 70e0f84 Compare December 2, 2019 17:03
/// ```
fn make_mut<L, C, D>(self, lens: L) -> MakeMut<Self, L, C>
where
Self: Sized + Lens<A, Arc<C>>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a hack, but it works.

@Ralith Ralith force-pushed the index branch 4 times, most recently from 13df44f to affb5be Compare December 2, 2019 18:04
@Ralith Ralith changed the title Deref, Index, and MakeMut lenses Deref, Index, and InArc lenses Dec 2, 2019
/// lens.put(&mut x, 42);
/// assert_eq!(&*x, &[0, 1, 42, 3]);
/// ```
fn in_arc(self) -> InArc<Self>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bikeshedding still welcome, though I think this is probably adequate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of anything better? maybe just arc, but either or.

@Ralith Ralith force-pushed the index branch 3 times, most recently from 4ed9487 to 6712b84 Compare December 3, 2019 03:33
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

druid/src/lens.rs Show resolved Hide resolved
druid/src/lens.rs Show resolved Hide resolved
@Ralith Ralith merged commit 6d9f725 into linebender:master Dec 3, 2019
@cmyr cmyr mentioned this pull request Dec 31, 2019
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants