You'll notice that, as of today, Rust is once again more picky about passing functions to higher-order functions. Each argument to each function is marked as either by-reference or by-value, and you can not pass a function expecting a by-value arg (`fn(+type)`) to a higher-order function that wants a by-ref function (`fn(&&type)`). The new system is different from the old (pre-my-alias-overhaul) approach in two ways:
- You don't have to explicitly annotate most functions. The compiler chooses a default passing convention (by-value for immediate types -- scalars, box/unique pointers, natives -- and by-ref for everything else). In practice, you only need to add a && in front of the arg name when your function takes something that defaults to by-value, but you need a function that passes by ref. - The 'ownership' of the arg stays with the caller, even for by-value args, so that we can usually avoid having to do a take and a drop on args. I think the result is pleasing. We don't have the constant clutter of ampersands in function signatures, but do get the performance benefits of using an appropriate and efficient passing style for each type. Having to line up passing styles for higher-order functions is a bit of a pain, but no more than it used to be before I started messing with call styles. I hope that at one point we'll monomorphize our generics (generate different version for different types), at which point we could simply make them call the given function in the right style, and remove this burden from the programmer. Best, Marijn _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
