Skip to content

Commit

Permalink
Rename Result::unwrap_infallible to into_ok
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabaluev committed Nov 4, 2019
1 parent 8f74bbb commit 6f6848f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,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(),
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/tests/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ! {
Expand All @@ -216,7 +216,7 @@ pub fn test_unwrap_infallible() {
Ok(667)
}

assert_eq!(infallible_op2().unwrap_infallible(), 667);
assert_eq!(infallible_op2().into_ok(), 667);
}

#[test]
Expand Down

0 comments on commit 6f6848f

Please sign in to comment.