Closed
Description
Because of let new = Index::new;
, a local shorthand to a static function, this code fails to compile. Moving the let new
down below fn inner
it will compile.
Error message:
<anon>:11:21: 11:31 error: can't capture dynamic environment in a fn item; use the || { ... } closure form instead
<anon>:11 let index = Index::new();
^~~~~~~~~~
struct Index;
impl Index {
fn new() -> Self { Index }
}
fn user() {
let new = Index::new;
fn inner() {
let index = Index::new();
}
let index2 = new();
}
fn main() {}
rust version: rustc 1.0.0-nightly (4874ca36f 2015-01-23 00:18:57 +0000)