Skip to content

Instantly share code, notes, and snippets.

@LukasKalbertodt

LukasKalbertodt/error.txt Secret

Last active Jun 21, 2017
Embed
What would you like to do?
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 | | }
| |_____^
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
You can’t perform that action at this time.