618
know the features of your language
(lemmy.world)
Post funny things about programming here! (Or just rant about your favourite programming language.)
The example even used unwrap_or_else where they should use unwrap_or. Then it uses
std::i64::MIN
as fallback value where they could use something like0
that would be a better example and honestly make more sense there.Even without trimming this to something less convoluted, the same functionality (with different fallback value) could be written in more readable form.
Obviously in the context of the page something like this would make way more sense:
Or perhaps more idiomatic version of the above:
I think you could even get rid of the
iter()
and thecollect()
since it's a small fixed size array.