Skip to content

Instantly share code, notes, and snippets.

@ende76
Created July 26, 2013 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ende76/6087033 to your computer and use it in GitHub Desktop.
Save ende76/6087033 to your computer and use it in GitHub Desktop.
This examples throws an error at compile time: does_not_fulfill_static.rs:5:32: 5:44 error: cannot capture variable of type `&[u8]`, which does not fulfill `'static`, in a bounded closure
use std::vec;
fn closure_with_captured_variables(target_bytes: &[u8], prefix: &[u8]) -> @fn(&[u8]) -> ~[u8] {
|bytes| {
vec::append(bytes.to_owned(), target_bytes)
}
}
fn main() {
println(fmt!("%?", closure_with_captured_variables([125u8, 65u8], [])));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment