Repository navigation
Conversation
|
cc @rust-lang/miri |
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| /// let x: Result<String, &str> = Ok("ownership".to_string()); | ||
| /// assert_eq!(x.as_ref().is_ok_or(|msg| msg.contains("i")), true); |
There was a problem hiding this comment.
Maybe it's clearer to change the error type to something other than a string and/or the Ok value was a string that doesn't pass the error predicate? Right now, the assertion would still pass if this was typo'd as is_ok_and or x was Err("ownership").
(I realize that the point of this example is to demonstrate how to use this without consuming the Result, but the other aspects of the example also draw attention because they're different from the previous examples.)
| /// let x: Result<String, &str> = Ok("ownership".to_string()); | ||
| /// assert_eq!(x.as_ref().is_err_or(|x| x.len() > 2), true); |
There was a problem hiding this comment.
Like above, I'd consider changing the error type or the Ok value so there's no confusing about why the result is true.
... now that I think about it, I would've expected an Err value here for symmetry with the as_ref().is_ok_or example. Maybe it's because I'm looking at both of these methods at the same time, but the spurious difference seems potentially confusing.
Notably, it is only used in tests in Miri, which are never run against the bootstrap sysroot. |
3d54885 to
f5b74b3
Compare
f5b74b3 to
dc08970
Compare
|
@bors r+ rollup |
implement Result::is_ok_or and Result::is_err_or ACP: rust-lang/libs-team#895 Tracking issue: rust-lang#166740
implement Result::is_ok_or and Result::is_err_or ACP: rust-lang/libs-team#895 Tracking issue: rust-lang#166740
ACP: rust-lang/libs-team#895
Tracking issue: #166740