2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(unused_variables)]
|
2015-03-31 16:09:24 +00:00
|
|
|
// Test that you can supply `&F` where `F: FnMut()`.
|
|
|
|
|
2016-07-13 14:07:11 +00:00
|
|
|
#![feature(lang_items)]
|
2015-03-31 16:09:24 +00:00
|
|
|
|
|
|
|
fn a<F:FnMut() -> i32>(mut f: F) -> i32 {
|
|
|
|
f()
|
|
|
|
}
|
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
fn b(f: &mut dyn FnMut() -> i32) -> i32 {
|
2015-03-31 16:09:24 +00:00
|
|
|
a(f)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn c<F:FnMut() -> i32>(f: &mut F) -> i32 {
|
|
|
|
a(f)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let z: isize = 7;
|
|
|
|
|
|
|
|
let x = b(&mut || 22);
|
|
|
|
assert_eq!(x, 22);
|
|
|
|
|
|
|
|
let x = c(&mut || 22);
|
|
|
|
assert_eq!(x, 22);
|
|
|
|
}
|