zlacker

[return to "Patterns for Defensive Programming in Rust"]
1. tayo42+EL1[view] [source] 2025-12-06 03:33:22
>>PaulHo+(OP)
>Using _ as a placeholder for unused variables can lead to confusion

I would have guessed linters would have complained about what's being suggested there. Is the something special about var: _ thing that avoids it?

◧◩
2. dwattt+Jl2[view] [source] 2025-12-06 11:59:04
>>tayo42+EL1
Underscore acts as a wildcard, denoting that you don't want to bind a variable. Quoting the Rust reference[0]:

> Underscore expressions, denoted with the symbol _, are used to signify a placeholder in a destructuring assignment.

[0]: https://doc.rust-lang.org/reference/expressions/underscore-e...

[go to top]