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

impl IntoIterator for &slice #11

Merged
merged 2 commits into from
Mar 10, 2018
Merged

impl IntoIterator for &slice #11

merged 2 commits into from
Mar 10, 2018

Conversation

inv2004
Copy link
Contributor

@inv2004 inv2004 commented Mar 10, 2018

Now it is possible to iterate over CheeseSlice by ref without moving .

Copy link
Member

@Luthaf Luthaf left a comment

Choose a reason for hiding this comment

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

This looks good to me, thank you for the pull-request !

@@ -136,6 +136,17 @@ pub fn derive(input: &Struct) -> Tokens {
}
}

impl<'a> IntoIterator for &'a #slice_name<'a> {
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually want the reference and the struct lifetime to be the same ? This could be impl<'a, 'b> IntoIterator for &'a #slice_name<'b> instead. I could see such case occurs in code like this

let slice =  cheese_vec.slice();
let ref = &slice;
// Do stuff with the reference

Or like this

let slice =  cheese_vec.slice();
do_stuff_with_reference(&slice);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed. Thank you for the review.

@Luthaf Luthaf merged commit 45cbb73 into lumol-org:master Mar 10, 2018
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