[rust-dev] Lifetime required to outlive itself

Scott Lawrence bytbox at gmail.com
Tue Jan 21 17:41:18 PST 2014

This code compiles successfully: http://ix.io/a34 . I believe this behavior is 
correct. Just so it's clear what this code does: f() takes a `&mut int` and 
adds it to an array - the idea is that all of the `&mut int` can be changed at 
some later time. Naturally, there's some fancy lifetime juggling involved in 
this (which I may have gotten wrong).

Uncommenting the commented parts (the method f() in the impl A, in particular) 
yields the error message shown at the bottom, which appears to say that the 
lifetime created in the second parameter of f() does not necessarily outlive 

Is there some especially complicated aspect of lifetimes as they interact 
with &self, or is this indeed a bug?

Scott Lawrence

More information about the Rust-dev mailing list