2017-02-28 05:35:00 -06:00
|
|
|
// allow(const_err) to work around a bug in warnings
|
|
|
|
#[allow(const_err)]
|
|
|
|
static FOO: fn() = || { assert_ne!(42, 43) };
|
|
|
|
#[allow(const_err)]
|
|
|
|
static BAR: fn(i32, i32) = |a, b| { assert_ne!(a, b) };
|
|
|
|
|
2018-08-27 10:08:42 -05:00
|
|
|
// use to first make the closure FnOnce() before making it fn()
|
|
|
|
fn magic<F: FnOnce()>(f: F) -> F { f }
|
|
|
|
|
2017-02-28 05:35:00 -06:00
|
|
|
fn main() {
|
|
|
|
FOO();
|
|
|
|
BAR(44, 45);
|
|
|
|
let bar: unsafe fn(i32, i32) = BAR;
|
|
|
|
unsafe { bar(46, 47) };
|
2019-05-30 03:58:30 -05:00
|
|
|
let boo: &dyn Fn(i32, i32) = &BAR;
|
2017-02-28 05:35:00 -06:00
|
|
|
boo(48, 49);
|
2018-08-27 10:08:42 -05:00
|
|
|
|
|
|
|
let f = magic(||{}) as fn();
|
|
|
|
f();
|
2017-02-28 05:35:00 -06:00
|
|
|
}
|