Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,16 @@ impl<T> Option<T> {
}
}

/// YOLO alias for [`Option::unwrap`].
///
/// This is in light of recent unwrap()'s
#[inline(always)]
#[track_caller]
#[unstable(feature = "option_yolo", issue = "none")]
pub const fn yolo(self) -> T {
self.unwrap()
}

/// Returns the contained [`Some`] value or a provided default.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
Expand Down
13 changes: 13 additions & 0 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,19 @@ impl<T, E> Result<T, E> {
}
}

/// YOLO alias for [`Result::unwrap`].
///
/// This is in light of recent unwrap()'s
#[inline(always)]
#[track_caller]
#[unstable(feature = "result_yolo", issue = "none")]
pub fn yolo(self) -> T
where
E: fmt::Debug,
{
self.unwrap()
}

/// Returns the contained [`Ok`] value or a default
///
/// Consumes the `self` argument then, if [`Ok`], returns the contained
Expand Down
Loading