]> git.lizzy.rs Git - rust.git/commitdiff
Also add a `From` implementation for `&mut Option<T>` -> `Option<&mut T>'
authorGeorg Semmler <georg_semmler_05@web.de>
Fri, 10 Aug 2018 12:21:17 +0000 (14:21 +0200)
committerGeorg Semmler <georg_semmler_05@web.de>
Fri, 10 Aug 2018 12:21:17 +0000 (14:21 +0200)
src/libcore/option.rs

index 883e01ff2a81b05e04a25658cfa0396b67e3692e..32a0a8b3c5106fcdabc3cb7b630ed649cde6368a 100644 (file)
@@ -1071,6 +1071,13 @@ fn from(o: &'a Option<T>) -> Option<&'a T> {
     }
 }
 
+#[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
 /////////////////////////////////////////////////////////////////////////////