3 ms·
Different, but related. If you call 'map' then you know you're not mutating the values, and you get an output the same size as the input without dropping values
by Filligree 7y ago
Different, but related. If you call 'map' then you know you're not mutating the values, and you get an output the same size as the input without dropping values, and...
It means you operate on a higher level of abstraction, and that inherently makes reading code faster. Not per line of code, but certainly per functional unit.
Idiomatic Rust tends to use a lot of functional code, and provides all the tools to make that safe. Its map function could mutate the input -- it would be unidiomatic, but certainly possible -- except that, if you don't pass a mutable reference, then you're safe to assume it won't.