]> git.lizzy.rs Git - rust.git/commitdiff
Mark `Option::insert` as must_use
authoroxalica <oxalicc@pm.me>
Fri, 16 Jul 2021 16:19:44 +0000 (00:19 +0800)
committeroxalica <oxalicc@pm.me>
Fri, 16 Jul 2021 16:19:44 +0000 (00:19 +0800)
library/core/src/option.rs

index b7af3ea8c1af4e5680cec669f5e88a0884eb4687..d1308549113225e34b95d53f62bad33b2deeade1 100644 (file)
@@ -1179,6 +1179,7 @@ pub fn xor(self, optb: Option<T>) -> Option<T> {
     /// *val = 3;
     /// assert_eq!(opt.unwrap(), 3);
     /// ```
+    #[must_use = "if you intended to set a value, consider assignment instead"]
     #[inline]
     #[stable(feature = "option_insert", since = "1.53.0")]
     pub fn insert(&mut self, value: T) -> &mut T {