2 ms·
I think the one here is legit (perhaps more realistic would be where you're passing the new array to an actual function that requires a certain array length).
by brundolf 4y ago
I think the one here is legit (perhaps more realistic would be where you're passing the new array to an actual function that requires a certain array length).
People always complain about Rust's type system being verbose- well, this makes it less verbose. It knows what you need from the function call, so it doesn't make you say it. And as an added benefit, if the required type ever changes in a way that can still be generated by the provided code (eg. the function you're passing to needs a different length), you won't need to update any explicit type annotations at the call-site.
If that's ever undesirable - you want to be very precise about your code - well, then you can do that too by specifying the generic parameters explicitly.