|
|
Subscribe / Log in / New account

Discarding return value, and ignoring return type

Discarding return value, and ignoring return type

Posted Sep 24, 2025 20:20 UTC (Wed) by duelafn (subscriber, #52974)
In reply to: Discarding return value, and ignoring return type by epa
Parent article: Canceling asynchronous Rust

That particular situation has a (disabled by default) lint: clippy::let_underscore_untyped.

    let _ = some_operation();

Gets a warning "consider adding a type annotation" which goes away if you do this:

    let _: Result<_,_> = some_operation();

Which would catch the async problem. I go one step further and make sure the Ok result type is also specified (Result<u64,_>, but the lint does not enforce that.


to post comments

Discarding return value, and ignoring return type

Posted Sep 25, 2025 11:22 UTC (Thu) by kpfleming (subscriber, #23250) [Link]

That's really useful and news to me, thanks for posting it!


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds