Did you know that in Rust, 'let _ = ...' and 'let _unused = ...' are NOT the same thing?
I didn't until today!
Did you know that in Rust, 'let _ = ...' and 'let _unused = ...' are NOT the same thing?
I didn't until today!
@pg Interesting! This lead me into a short rabbithole. This is what I found:
- let _ = ... is pattern matching (https://doc.rust-lang.org/stable/reference/patterns.html#grammar-WildcardPattern states: "Unlike identifier patterns, it does not copy, move or borrow the value it matches")
- let _unused = ... assignes a variable (which is only unused by convention)
If you follow the reference carefully, it turns out that _ is not a valid identifier! It is actually a keyword (https://doc.rust-lang.org/stable/reference/keywords.html#r-lex.keywords.strict)
TIL