Rename Result::unwrap_infallible to into_ok
This commit is contained in:
parent
9a99a2159b
commit
6f0672c08b
@ -1109,11 +1109,11 @@ impl<T, E: Into<!>> Result<T, E> {
|
||||
/// Ok("this is fine".into())
|
||||
/// }
|
||||
///
|
||||
/// let s: String = only_good_news().unwrap_infallible();
|
||||
/// let s: String = only_good_news().into_ok();
|
||||
/// println!("{}", s);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn unwrap_infallible(self) -> T {
|
||||
pub fn into_ok(self) -> T {
|
||||
match self {
|
||||
Ok(x) => x,
|
||||
Err(e) => e.into(),
|
||||
|
@ -198,12 +198,12 @@ pub fn test_unwrap_or_default() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_unwrap_infallible() {
|
||||
pub fn test_into_ok() {
|
||||
fn infallible_op() -> Result<isize, !> {
|
||||
Ok(666)
|
||||
}
|
||||
|
||||
assert_eq!(infallible_op().unwrap_infallible(), 666);
|
||||
assert_eq!(infallible_op().into_ok(), 666);
|
||||
|
||||
enum MyNeverToken {}
|
||||
impl From<MyNeverToken> for ! {
|
||||
@ -216,7 +216,7 @@ fn infallible_op2() -> Result<isize, MyNeverToken> {
|
||||
Ok(667)
|
||||
}
|
||||
|
||||
assert_eq!(infallible_op2().unwrap_infallible(), 667);
|
||||
assert_eq!(infallible_op2().into_ok(), 667);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user