Rollup merge of #53218 - weiznich:feature/option_ref_into, r=KodrAus
Add a implementation of `From` for converting `&'a Option<T>` into `Option<&'a T>` I'm not sure if any annotations regarding the stabilization are needed or in general what's the correct process of adding such an impl. cc @sgrif (We have talked about this)
This commit is contained in:
commit
b3303edba6
@ -1062,6 +1062,20 @@ impl<T> From<T> for Option<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "option_ref_from_ref_option", since = "1.30.0")]
|
||||
impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
|
||||
fn from(o: &'a Option<T>) -> Option<&'a T> {
|
||||
o.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "option_ref_from_ref_option", since = "1.30.0")]
|
||||
impl<'a, T> From<&'a mut Option<T>> for Option<&'a mut T> {
|
||||
fn from(o: &'a mut Option<T>) -> Option<&'a mut T> {
|
||||
o.as_mut()
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The Option Iterators
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user