[libcxx-commits] [libcxx] [libc++] mark `std::expected` as `nodiscard` (PR #130820)
Mohamed Emad via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 24 05:16:46 PDT 2025
hulxv wrote:
> I'm conflicted about making this change -- I suspect this could end up being really verbose. Before we actually land this, can you please ping @llvm/libcxx-vendors to give folks a chance to run this change internally first? I'd like to try that out to get some signal.
I came from a Rust background and we have `Result` that does the same behaviour as `std::expected`, the compiler warning us directly if this result isn't handled or assigned to a variable
```rs
let res: Result<T,E> = result_return_result(); // no warning
result_return_result(); // WARNING!!!
result_return_result().unwrap(); // no warning. ".unwrap()" works as a handler and returns the expected value
```
So, I don't find it a verbose thing and it's normal from my point of view
https://github.com/llvm/llvm-project/pull/130820
More information about the libcxx-commits
mailing list