Small habit I’ve picked up in Rust: There’s a “drop” function, imported by default, that just ignores its argument and returns unit. I use it when I want to make clear to the reader that I’m intentionally ignoring a value.
-
-
Hmm, I think it's clear only when you actually want to deallocate something (hence `drop`). If it's just to ignore I find `let _ = ...` clearer.
-
I agree
@RReverser, I've used both in those same contexts and never considered using drop as a note to a reader that I'm not interested in the result. I've only used it when wanting to deallocate something in a more explicit manner than scoping the value. - 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.