rust/tests/ui/unboxed-closures/unboxed-closures-blanket-fn-mut.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
420 B
Rust
Raw Normal View History

//@ run-pass
#![allow(unused_variables)]
2015-03-31 16:09:24 +00:00
// Test that you can supply `&F` where `F: FnMut()`.
#![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);
}