Skip to content

Commit 6cf2773

Browse files
committed
Result::unwrap_infallible: change doctest
Changed the example to code that compiles now.
1 parent dbef313 commit 6cf2773

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/libcore/result.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,15 @@ impl<T, E: Into<!>> Result<T, E> {
10791079
/// Basic usage:
10801080
///
10811081
/// ```
1082-
/// let x = u64::try_from(42u32).unwrap_infallible();
1083-
/// assert_eq!(x, 42u64);
1082+
/// # #![feature(never_type)]
1083+
/// # #![feature(unwrap_infallible)]
1084+
///
1085+
/// fn only_good_news() -> Result<String, !> {
1086+
/// Ok("this is fine".into())
1087+
/// }
1088+
///
1089+
/// let s: String = only_good_news().unwrap_infallible();
1090+
/// println!("{}", s);
10841091
/// ```
10851092
#[inline]
10861093
pub fn unwrap_infallible(self) -> T {

0 commit comments

Comments
 (0)