Skip to content

Commit 05acd9c

Browse files
committed
Mark map_or as #[must_use]
1 parent 63eb03e commit 05acd9c

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

core/src/option.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ impl<T> Option<T> {
11251125
/// ```
11261126
#[inline]
11271127
#[stable(feature = "rust1", since = "1.0.0")]
1128+
#[must_use = "if you don't need the returned value, use `if let` instead"]
11281129
pub fn map_or<U, F>(self, default: U, f: F) -> U
11291130
where
11301131
F: FnOnce(T) -> U,

core/src/result.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ impl<T, E> Result<T, E> {
768768
/// ```
769769
#[inline]
770770
#[stable(feature = "result_map_or", since = "1.41.0")]
771+
#[must_use = "if you don't need the returned value, use `if let` instead"]
771772
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
772773
match self {
773774
Ok(t) => f(t),

0 commit comments

Comments
 (0)