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

Implement mutable iteration #3

Open
steveklabnik opened this issue Sep 14, 2018 · 2 comments
Open

Implement mutable iteration #3

steveklabnik opened this issue Sep 14, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@steveklabnik
Copy link
Owner

Make an iter_mut to go along with iter.

@steveklabnik steveklabnik added enhancement New feature or request help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Sep 14, 2018
@cauebs
Copy link
Contributor

cauebs commented Sep 15, 2018

I gave this one a try, but it wasn't as trivial as it seemed.

error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements
   --> src/lib.rs:959:20
    |
959 |         match &mut self.list.contents[next_index] {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 954:5...
   --> src/lib.rs:954:5
    |
954 | /     fn next(&mut self) -> Option<Self::Item> {
955 | |         // do we have a next thing?
956 | |         let next_index = self.next_index?;
957 | |
...   |
967 | |         }
968 | |     }
    | |_____^
note: ...so that reference does not outlive borrowed content
   --> src/lib.rs:959:20
    |
959 |         match &mut self.list.contents[next_index] {
    |                    ^^^^^^^^^^^^^^^^^^
note: but, the lifetime must be valid for the lifetime 'a as defined on the impl at 951:6...
   --> src/lib.rs:951:6
    |
951 | impl<'a, T> Iterator for IterMut<'a, T> {
    |      ^^
    = note: ...so that the types are compatible:
            expected std::iter::Iterator
               found std::iter::Iterator

@steveklabnik
Copy link
Owner Author

Hm, interesting. I'll have to give it a shot sometime too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants