Last active
December 17, 2016 02:42
-
-
Save azriel91/82e08a364bd91dfcf5bb087c5c44f071 to your computer and use it in GitHub Desktop.
Minimal example to reproduce issue
This file contains hidden or 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
trait Task {} | |
trait Display {} | |
struct SomethingTask<'d> { | |
displays: Vec<&'d Display>, | |
} | |
impl<'d> Task for SomethingTask<'d> {} | |
struct MyDisplay; | |
impl Display for MyDisplay {} | |
struct Engine { | |
tasks: Vec<Box<Task>>, | |
} | |
fn main() { | |
let my_display = MyDisplay; | |
let displays = vec![&my_display as &Display]; | |
// ^^^^^^^^^^ does not live long enough | |
let task: Box<Task> = Box::new(SomethingTask { displays: displays }); | |
let tasks = vec![task]; | |
Engine { tasks: tasks }; | |
} | |
// - borrowed value only lives until here | |
// = note: borrowed value must be valid for the static lifetime... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment