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:
Jonathan Brouwer 2026-01-22 13:35:39 +01:00 committed by GitHub
commit 4fb420afa5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
}
}