]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
5bcae85e | 11 | #![feature(lang_items)] |
1a4d82fc | 12 | |
c34b1796 | 13 | fn a<F:Fn(isize, isize) -> isize>(f: F) -> isize { |
1a4d82fc JJ |
14 | f(1, 2) |
15 | } | |
16 | ||
c34b1796 | 17 | fn b<F:FnMut(isize, isize) -> isize>(mut f: F) -> isize { |
1a4d82fc JJ |
18 | f(3, 4) |
19 | } | |
20 | ||
c34b1796 | 21 | fn c<F:FnOnce(isize, isize) -> isize>(f: F) -> isize { |
1a4d82fc JJ |
22 | f(5, 6) |
23 | } | |
24 | ||
25 | fn main() { | |
c34b1796 AL |
26 | let z: isize = 7; |
27 | assert_eq!(a(move |x: isize, y| x + y + z), 10); | |
28 | assert_eq!(b(move |x: isize, y| x + y + z), 14); | |
29 | assert_eq!(c(move |x: isize, y| x + y + z), 18); | |
1a4d82fc | 30 | } |