about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-07-30 14:25:08 +0200
committerGitHub <noreply@github.com>2023-07-30 14:25:08 +0200
commite3bf088fb5e339a030d200e0acf190a10104da80 (patch)
tree1d680d83d8fd3024f17a55adeff5e99b871fdce5 /library/core/src
parente517ee02b2cd040408657b07b28c97a729d897ea (diff)
parent90f9640528d9ea9930a4da586a1c6079dd7e5720 (diff)
downloadrust-e3bf088fb5e339a030d200e0acf190a10104da80.tar.gz
rust-e3bf088fb5e339a030d200e0acf190a10104da80.zip
Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee
Mark `map_or` as `#[must_use]`

I don't know what else to say.

r? libs
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 51b7616ffec..6981abc9be1 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),