3 ms·
A slightly related note: you can get similar behavior in C (and C++) with compiler extensions. In GCC and clang marking function with '__attribute__((warn_unuse
by mbel 9y ago
A slightly related note: you can get similar behavior in C (and C++) with compiler extensions. In GCC and clang marking function with '__attribute__((warn_unused_result))' will produce a warning if function is called without using the result. Equivalent for MSVC is '_Check_return_'.
Obviously this is not nearly as convenient as your Rust example, but enables some of its the benefits.
- gpderetta 9y agoC++17 has (will have?) [[nodiscard]] with the same semantics.