Skip to content

Instantly share code, notes, and snippets.

@hadronized
Created March 22, 2016 20:09
Show Gist options
  • Save hadronized/d74cc0883e79d1863cd0 to your computer and use it in GitHub Desktop.
Save hadronized/d74cc0883e79d1863cd0 to your computer and use it in GitHub Desktop.
fn test() -> Foo {
let i = 3;
Foo {
updater: Box::new(|| println!("{}", &i))
}
}
Compiling luminance v0.1.0 (file:///home/phaazon/dev/luminance-rs)
src/render.rs:35:23: 35:44 error: closure may outlive the current function, but it borrows `i`, which is owned by the current function [E0373]
src/render.rs:35 updater: Box::new(|| println!("{}", &i))
^~~~~~~~~~~~~~~~~~~~~
src/render.rs:35:23: 35:44 help: run `rustc --explain E0373` to see a detailed explanation
src/render.rs:35:42: 35:43 note: `i` is borrowed here
src/render.rs:35 updater: Box::new(|| println!("{}", &i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment