I've used F# before, which requires all return values to be explicitly used. If a return value is not needed, you need to drop it explicitly (using let _ = val
which is the same as in Rust, or using F#-style |> ignore
, the function ignore
is equivalent to std::mem::drop
). In Rust, this seems to be equivalent to making all functions that don't return unit must_use
.
This already exists, as the lint unused_results
.
#![deny(unused_results)]
Ignoring the return value of a function may indicate a mistake. In cases were it is almost certain that the result should be used, it is recommended to annotate the function with the
must_use
attribute. Failure to use such a return value will trigger theunused_must_use
lint which is warn-by-default. Theunused_results
lint is essentially the same, but triggers for all return values.
3 Likes
Well... almost.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.