5 ms·
Perhaps you meant that variables which are closed over are in an anonymous struct or in a tuple. I am fuzzy about the details but as far as I know parameters ar
by _nalply 5y ago
Perhaps you meant that variables which are closed over are in an anonymous struct or in a tuple. I am fuzzy about the details but as far as I know parameters are passed like as in other functions.
- estebank 5y agoRust represents closures in the following way: pub trait Fn<Args> { type Output; extern "rust-call" fn call(self, args: Args) -> Self::Output; } where Args is a tuple of all the actual arguments. You used to be able to cause an ICE on nightly if you used something other than the correct argument[1], but instead it now tells you that it should have been a tuple: error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple --> src/main.rs:7:5 | 7 | extern "rust-call" fn call_once(self, args: i32) -> Self::Output {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit --> src/main.rs:12:5 | 12 | x(42); | ^^^^^ [1]: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=9b66c97982c370bc865597301af2ae7e https://play.rust-lang.org/?version=nightly&mode=debug&editi...
- _nalply 5y agoHuh. That's really slick. I stand corrected.