mi sto cercando di fare questo semplice compilare il codice:La funzione ruggine non ha una durata statica?
fn dox(x: u8) -> u8 { x*2 }
fn main() {
let cb: &'static (Fn(u8) -> u8) = &dox;
}
ma non riesce a Rust 1.9:
x.rs:4:40: 4:43 error: borrowed value does not live long enough
x.rs:4 let cb: &'static (Fn(u8) -> u8) = &dox;
^~~
note: reference must be valid for the static lifetime...
x.rs:4:44: 5:2 note: ...but borrowed value is only valid for the block suffix following statement 0 at 4:43
x.rs:4 let cb: &'static (Fn(u8) -> u8) = &dox;
x.rs:5 }
error: aborting due to previous error
Come è possibile che una funzione libera non ha vita statica? In che modo questo codice potrebbe non essere sicuro?