2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2016-07-13 14:07:11 +00:00
|
|
|
#![feature(lang_items)]
|
2014-07-30 05:08:39 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn a<F:Fn(isize, isize) -> isize>(f: F) -> isize {
|
2014-07-30 05:08:39 +00:00
|
|
|
f(1, 2)
|
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn b<F:FnMut(isize, isize) -> isize>(mut f: F) -> isize {
|
2014-07-30 05:08:39 +00:00
|
|
|
f(3, 4)
|
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn c<F:FnOnce(isize, isize) -> isize>(f: F) -> isize {
|
2014-07-30 05:08:39 +00:00
|
|
|
f(5, 6)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2015-03-26 00:06:52 +00: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 05:08:39 +00:00
|
|
|
}
|