2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2016-07-13 09:07:11 -05:00
|
|
|
#![feature(lang_items)]
|
2014-07-30 00:08:39 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn a<F:Fn(isize, isize) -> isize>(f: F) -> isize {
|
2014-07-30 00:08:39 -05:00
|
|
|
f(1, 2)
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn b<F:FnMut(isize, isize) -> isize>(mut f: F) -> isize {
|
2014-07-30 00:08:39 -05:00
|
|
|
f(3, 4)
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn c<F:FnOnce(isize, isize) -> isize>(f: F) -> isize {
|
2014-07-30 00:08:39 -05:00
|
|
|
f(5, 6)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2015-03-25 19:06:52 -05:00
|
|
|
let z: isize = 7;
|
|
|
|
assert_eq!(a(move |x: isize, y| x + y + z), 10);
|
|
|
|
assert_eq!(b(move |x: isize, y| x + y + z), 14);
|
|
|
|
assert_eq!(c(move |x: isize, y| x + y + z), 18);
|
2014-07-30 00:08:39 -05:00
|
|
|
}
|