Fn
2022/2/26 8:24:00
fn test<T>(closure:T) where T: Fn(u32) -> u32 {
assert_eq!(closure(10), 11);
}
let closure = |x| {
x+1
};
test(closure);
fn test(closure: impl Fn(u32)->u32) {
assert_eq!(closure(10), 11);
}
let closure = |x| {
x+1
};
test(closure);
fn test<T: Fn(u32)->u32>(closure:T) {
assert_eq!(closure(10), 11);
}
let closure = |x:u32|-> u32 {
x+1
};
test(closure);