zlacker
[return to "Patterns for Defensive Programming in Rust"]
◧
1. swiftc+X52
[view]
[source]
2025-12-06 08:34:15
>>PaulHo+(OP)
In the first example, the match feels extremely overkill. Vec.first() exposes the correct semantic (as does Vec.iter().nth(0) for the more general case), returning an Option.
◧◩
2. fvncc+7g2
[view]
[source]
2025-12-06 10:51:40
>>swiftc+X52
Note its possible to write the example more succinctly (while having the same behavior) with:
https://docs.rs/itertools/latest/itertools/trait.Itertools.h...
[go to top]