-
-
Save LukasKalbertodt/84181baba864d58d4a09d966ac2d9ebc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements | |
--> src/lib.rs:459:23 | |
| | |
459 | Some(&mut self.sv.data[1]) | |
| ^^^^^^^^^^^^^^^ | |
| | |
note: first, the lifetime cannot outlive the lifetime 'b as defined on the body at 450:52... | |
--> src/lib.rs:450:53 | |
| | |
450 | fn next<'b>(&'b mut self) -> Option<Self::Item> { | |
| _____________________________________________________^ | |
451 | | if self.pos == self.sv.data.len() { | |
452 | | None | |
453 | | } else { | |
... | | |
460 | | } | |
461 | | } | |
| |_____^ | |
note: ...so that reference does not outlive borrowed content | |
--> src/lib.rs:459:23 | |
| | |
459 | Some(&mut self.sv.data[1]) | |
| ^^^^^^^^^^^^ | |
note: but, the lifetime must be valid for the lifetime 'a as defined on the body at 450:52... | |
--> src/lib.rs:450:53 | |
| | |
450 | fn next<'b>(&'b mut self) -> Option<Self::Item> { | |
| _____________________________________________________^ | |
451 | | if self.pos == self.sv.data.len() { | |
452 | | None | |
453 | | } else { | |
... | | |
460 | | } | |
461 | | } | |
| |_____^ | |
note: ...so that types are compatible (expected std::iter::Iterator, found std::iter::Iterator) | |
--> src/lib.rs:450:53 | |
| | |
450 | fn next<'b>(&'b mut self) -> Option<Self::Item> { | |
| _____________________________________________________^ | |
451 | | if self.pos == self.sv.data.len() { | |
452 | | None | |
453 | | } else { | |
... | | |
460 | | } | |
461 | | } | |
| |_____^ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct IterMut<'a, T: 'a> { | |
sv: &'a mut StableVec<T>, | |
pos: usize, | |
} | |
impl<'a, T> Iterator for IterMut<'a, T> { | |
type Item = &'a mut T; | |
fn next<'b>(&'b mut self) -> Option<Self::Item> { | |
if self.pos == self.sv.data.len() { | |
None | |
} else { | |
while self.sv.deleted[self.pos] { | |
self.pos += 1; | |
} | |
self.pos += 1; | |
Some(&mut self.sv.data[1]) // <-- `self.sv.data` is a `Vec<T>` | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment