2022-07-30 05:37:48 +00:00
|
|
|
#![feature(unboxed_closures,tuple_trait)]
|
2014-05-29 05:26:56 +00:00
|
|
|
|
|
|
|
use std::ops::FnMut;
|
|
|
|
|
2022-07-30 05:37:48 +00:00
|
|
|
fn to_fn_mut<A:std::marker::Tuple, F:FnMut<A>>(f: F) -> F { f }
|
2015-02-03 16:32:26 +00:00
|
|
|
|
2022-07-28 15:33:10 +00:00
|
|
|
fn call_it<F: FnMut(isize, isize) -> isize>(y: isize, mut f: F) -> isize {
|
|
|
|
//~^ NOTE required by this bound in `call_it`
|
|
|
|
//~| NOTE required by a bound in `call_it`
|
2015-01-05 19:07:10 +00:00
|
|
|
f(2, y)
|
2014-05-29 05:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
2015-02-03 16:32:26 +00:00
|
|
|
let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y });
|
2022-07-28 15:33:10 +00:00
|
|
|
//~^ NOTE found signature defined here
|
2015-01-12 15:27:25 +00:00
|
|
|
let z = call_it(3, f);
|
|
|
|
//~^ ERROR type mismatch
|
2022-07-28 15:33:10 +00:00
|
|
|
//~| NOTE expected due to this
|
|
|
|
//~| NOTE expected closure signature `fn(isize, _) -> _`
|
2021-09-07 11:30:53 +00:00
|
|
|
//~| NOTE required by a bound introduced by this call
|
2014-05-29 05:26:56 +00:00
|
|
|
println!("{}", z);
|
|
|
|
}
|