diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-07-30 14:25:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-30 14:25:08 +0200 |
| commit | e3bf088fb5e339a030d200e0acf190a10104da80 (patch) | |
| tree | 1d680d83d8fd3024f17a55adeff5e99b871fdce5 /library/core/src | |
| parent | e517ee02b2cd040408657b07b28c97a729d897ea (diff) | |
| parent | 90f9640528d9ea9930a4da586a1c6079dd7e5720 (diff) | |
| download | rust-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.rs | 1 | ||||
| -rw-r--r-- | library/core/src/result.rs | 1 |
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), |
