Skip to content

Commit

Permalink
Rename Result::ok_or_err to Result::into_ok_or_err
Browse files Browse the repository at this point in the history
  • Loading branch information
thomcc committed Feb 17, 2021
1 parent 7d30366 commit 2711b01
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1294,16 +1294,16 @@ impl<T> Result<T, T> {
/// # Examples
///
/// ```
/// #![feature(ok_or_err)]
/// #![feature(result_into_ok_or_err)]
/// let ok: Result<u32, u32> = Ok(3);
/// let err: Result<u32, u32> = Err(4);
///
/// assert_eq!(ok.ok_or_err(), 3);
/// assert_eq!(err.ok_or_err(), 4);
/// assert_eq!(ok.into_ok_or_err(), 3);
/// assert_eq!(err.into_ok_or_err(), 4);
/// ```
#[inline]
#[unstable(feature = "ok_or_err", reason = "newly added", issue = "none")]
pub const fn ok_or_err(self) -> T {
#[unstable(feature = "result_into_ok_or_err", reason = "newly added", issue = "none")]
pub const fn into_ok_or_err(self) -> T {
match self {
Ok(v) => v,
Err(v) => v,
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#![feature(never_type)]
#![feature(unwrap_infallible)]
#![feature(option_result_unwrap_unchecked)]
#![feature(ok_or_err)]
#![feature(result_into_ok_or_err)]
#![feature(option_unwrap_none)]
#![feature(peekable_peek_mut)]
#![feature(once_cell)]
Expand Down
4 changes: 2 additions & 2 deletions library/core/tests/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ fn test_ok_or_err() {
let ok: Result<isize, isize> = Ok(100);
let err: Result<isize, isize> = Err(200);

assert_eq!(ok.ok_or_err(), 100);
assert_eq!(err.ok_or_err(), 200);
assert_eq!(ok.into_ok_or_err(), 100);
assert_eq!(err.into_ok_or_err(), 200);
}

#[test]
Expand Down

0 comments on commit 2711b01

Please sign in to comment.