2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_imports)]
|
2015-01-02 14:30:26 -06:00
|
|
|
// Test that the call operator autoderefs when calling a bounded type parameter.
|
|
|
|
|
|
|
|
use std::ops::FnMut;
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn call_with_2(x: &fn(isize) -> isize) -> isize
|
2015-01-02 14:30:26 -06:00
|
|
|
{
|
|
|
|
x(2) // look ma, no `*`
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn subtract_22(x: isize) -> isize { x - 22 }
|
2015-01-02 14:30:26 -06:00
|
|
|
|
|
|
|
pub fn main() {
|
2015-03-25 19:06:52 -05:00
|
|
|
let subtract_22: fn(isize) -> isize = subtract_22;
|
2015-01-02 14:30:26 -06:00
|
|
|
let z = call_with_2(&subtract_22);
|
|
|
|
assert_eq!(z, -20);
|
|
|
|
}
|