Skip to content

Commit 6f6848f

Browse files
committed
Rename Result::unwrap_infallible to into_ok
1 parent 8f74bbb commit 6f6848f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/libcore/result.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,11 @@ impl<T, E: Into<!>> Result<T, E> {
10861086
/// Ok("this is fine".into())
10871087
/// }
10881088
///
1089-
/// let s: String = only_good_news().unwrap_infallible();
1089+
/// let s: String = only_good_news().into_ok();
10901090
/// println!("{}", s);
10911091
/// ```
10921092
#[inline]
1093-
pub fn unwrap_infallible(self) -> T {
1093+
pub fn into_ok(self) -> T {
10941094
match self {
10951095
Ok(x) => x,
10961096
Err(e) => e.into(),

src/libcore/tests/result.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ pub fn test_unwrap_or_default() {
198198
}
199199

200200
#[test]
201-
pub fn test_unwrap_infallible() {
201+
pub fn test_into_ok() {
202202
fn infallible_op() -> Result<isize, !> {
203203
Ok(666)
204204
}
205205

206-
assert_eq!(infallible_op().unwrap_infallible(), 666);
206+
assert_eq!(infallible_op().into_ok(), 666);
207207

208208
enum MyNeverToken {}
209209
impl From<MyNeverToken> for ! {
@@ -216,7 +216,7 @@ pub fn test_unwrap_infallible() {
216216
Ok(667)
217217
}
218218

219-
assert_eq!(infallible_op2().unwrap_infallible(), 667);
219+
assert_eq!(infallible_op2().into_ok(), 667);
220220
}
221221

222222
#[test]

0 commit comments

Comments
 (0)