Closed
Description
Code:
fn baz(f: &fn()) {
let g = f;
let h = f;
}
fails with:
/.../tmp.rs:3:12: 3:13 error: use of moved value: `f`
/.../tmp.rs:3 let h = f;
^
/.../tmp.rs:2:12: 2:13 note: `f` moved here because it has type `&fn<no-bounds>()`, which is moved by default (use `copy` to override)
/.../tmp.rs:2 let g = f;
Similar problem:
fn foo(fs: &[&fn()]) {
let f = fs[0];
}
Fails with:
/.../tmp.rs:2:12: 2:16 error: cannot move out of dereference of & pointer
/.../tmp.rs:2 let f = fs[0];
Because of this it seems to be impossible to iterate over &[&fn()]
.
Metadata
Metadata
Assignees
Labels
No labels