Last active
January 2, 2016 03:08
-
-
Save bvssvni/8241479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn add<T: Add<T, T>>( | |
a: proc() -> T, | |
b: proc() -> T | |
) -> proc() -> T { | |
proc() a() + b() | |
} | |
fn main() { | |
let a = proc() 2; | |
let b = proc() 3; | |
let c = add(a, b); | |
let d = c(); | |
println!("{}", d); | |
let e = c(); | |
println!("{}", e); | |
} | |
Compiler error: | |
/home/sven/Desktop/prob/src/closure/main.rs:15:9: 15:10 error: use of moved value: `c` | |
/home/sven/Desktop/prob/src/closure/main.rs:15 let e = c(); | |
^ | |
/home/sven/Desktop/prob/src/closure/main.rs:13:9: 13:10 note: `c` moved here because it has type `proc:Send() -> int`, which is non-copyable (perhaps you meant to use clone()?) | |
/home/sven/Desktop/prob/src/closure/main.rs:13 let d = c(); | |
^ | |
error: aborting due to previous error | |
task '<unnamed>' failed at 'explicit failure', /home/sven/Desktop/rust/src/libsyntax/diagnostic.rs:102 | |
task '<unnamed>' failed at 'receiving on a closed channel', /home/sven/Desktop/rust/src/libstd/comm/mod.rs:728 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment