Example 2
- We need to annotate conversion a bit to handle immutable reference parameters.
- There is no (positive) trait that distinguish immutable references and unboxed values.
use any_fn::{r#fn, Ref, value};
fn foo(x: usize, y: &usize, z: &mut usize) {
*z = x + *y;
}
let x = value(0usize);
r#fn::<(_, Ref<_>, _), _>(foo)
.call(&[&value(40usize), &value(2usize), &x])
.unwrap();
assert_eq!(*x.downcast_ref::<usize>().unwrap(), 42);