Rollup merge of #151220 - cvengler:map-option, r=tgross35
option: Use Option::map in Option::cloned This commit removes a repetitive match statement in favor of Option::map for Option::cloned.
This commit is contained in:
commit
4fb420afa5
1 changed files with 2 additions and 8 deletions
|
|
@ -2103,10 +2103,7 @@ impl<T> Option<&T> {
|
|||
where
|
||||
T: Clone,
|
||||
{
|
||||
match self {
|
||||
Some(t) => Some(t.clone()),
|
||||
None => None,
|
||||
}
|
||||
self.map(T::clone)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2154,10 +2151,7 @@ impl<T> Option<&mut T> {
|
|||
where
|
||||
T: Clone,
|
||||
{
|
||||
match self {
|
||||
Some(t) => Some(t.clone()),
|
||||
None => None,
|
||||
}
|
||||
self.as_deref().map(T::clone)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue