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 Ref lens and use move semantics for lens! macro index. #1171

Merged
merged 4 commits into from
Sep 3, 2020

Conversation

luleyleo
Copy link
Collaborator

@luleyleo luleyleo commented Sep 1, 2020

Closes #1138.

See the linked issue for the reasoning behind this.

@luleyleo luleyleo added the S-needs-review waits for review label Sep 1, 2020
@@ -125,6 +125,51 @@ pub trait LensExt<A: ?Sized, B: ?Sized>: Lens<A, B> {
self.then(Deref)
}

/// Invoke a type's `AsRef` and `AsMut` impl.
///
/// It also allows indexing arrays with the [`index`] lens as shown in the example.
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe worth explaining that this is because Index is implemented for slices, and not arrays. Otherwise it's a little mysterious (to me, anyway) why reffing allowing indexing to work

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea! I've added a note.

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 very sensible to me.

@luleyleo luleyleo removed the S-needs-review waits for review label Sep 2, 2020
@cmyr
Copy link
Member

cmyr commented Sep 2, 2020

this will need a rebase to pass CI.

@luleyleo luleyleo merged commit a8fb9ca into linebender:master Sep 3, 2020
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.

lens::Index does not work on arrays
3 participants