Auto merge of #87196 - oxalica:option-insert-must-use, r=joshtriplett

Mark `Option::insert` as must_use

Some people seems misled by the function name and use it in case where a simple assignment just works.
If the return value is not used, `option = Some(value);` should be preferred instead of `option.insert(value);`
This commit is contained in:
bors 2021-07-19 07:03:36 +00:00
commit 83f08223a9

View 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 {