logoalt Hacker News

bayesnetyesterday at 2:13 PM2 repliesview on HN

It’s also worth noting that in rust you don’t need to be as worried about marking a function #[must_use] if there is a valid reason some of the time to discard the value. One can just assign like so `let _ = must_use_fn()` which discards the value and silences the warning. I think this makes the intent more clear than casting to void as TFA discusses.


Replies

OptionOfTtoday at 5:07 AM

Careful. I don't like the use of `let _ =` in general, as it instantly drops.

And you don't get a compilation failure when the type on the right hand side changes. This is even more important if it switches from non-drop to drop. There is a clippy lint for this.

on_the_trainyesterday at 2:22 PM

There is in c++, too (std::ignore). Not sure why the author decided to go with the ancient void cast

show 3 replies