about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2023-06-15 13:15:52 +0000
committerMaybe Waffle <waffle.lapkin@gmail.com>2023-07-30 10:22:23 +0000
commit90f9640528d9ea9930a4da586a1c6079dd7e5720 (patch)
tree1eac4efb20ae047b41f68f46d0fd4447a4c84b2d /library/core/src
parent5a65be815211a059b08ee3b786583308377372fa (diff)
downloadrust-90f9640528d9ea9930a4da586a1c6079dd7e5720.tar.gz
rust-90f9640528d9ea9930a4da586a1c6079dd7e5720.zip
Mark `map_or` as `#[must_use]`
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/option.rs1
-rw-r--r--library/core/src/result.rs1
2 files changed, 2 insertions, 0 deletions
diff --git a/library/core/src/option.rs b/library/core/src/option.rs
index 9b6ff76b240..1020e655579 100644
--- a/library/core/src/option.rs
+++ b/library/core/src/option.rs
@@ -1125,6 +1125,7 @@ impl<T> Option<T> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[must_use = "if you don't need the returned value, use `if let` instead"]
     pub fn map_or<U, F>(self, default: U, f: F) -> U
     where
         F: FnOnce(T) -> U,
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index 1ee270f4c03..89c0f0217e7 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -768,6 +768,7 @@ impl<T, E> Result<T, E> {
     /// ```
     #[inline]
     #[stable(feature = "result_map_or", since = "1.41.0")]
+    #[must_use = "if you don't need the returned value, use `if let` instead"]
     pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
         match self {
             Ok(t) => f(t),