let sig = function.get_signature();
assert_eq!(Type::get::<R>(ctx), sig.get_return());
let arg = Type::get::<A>(ctx);
if let Some(args) = StructType::cast(arg) {
assert_eq!(sig.get_params(), args.get_elements());
} else {
assert_eq!(arg, sig.get_return());
}
In particular, when the StructType::cast(arg) returns None, it is checking that the return type of the signature matches ... the argument type to the callback (and this is after we have already confirmed that the return type of the signature matches the return type of the callback).
Was this a mistake -- i.e. was your intention to instead assert in the else branch that [arg] == sig.get_params(), (in other words, implicitly promoting a non-struct argument for the callback to a singleton list) ?
Or is there some hidden reasoning behind this that I am missing?
The logic in
fn with_function
here seems weird:In particular, when the
StructType::cast(arg)
returnsNone
, it is checking that the return type of the signature matches ... the argument type to the callback (and this is after we have already confirmed that the return type of the signature matches the return type of the callback).Was this a mistake -- i.e. was your intention to instead assert in the else branch that
[arg] == sig.get_params()
, (in other words, implicitly promoting a non-struct argument for the callback to a singleton list) ?Or is there some hidden reasoning behind this that I am missing?