]> git.lizzy.rs Git - rust.git/commitdiff
Consolidate impl Option<&mut T>
authorDavid Tolnay <dtolnay@gmail.com>
Thu, 30 Dec 2021 18:37:50 +0000 (10:37 -0800)
committerDavid Tolnay <dtolnay@gmail.com>
Thu, 30 Dec 2021 18:37:53 +0000 (10:37 -0800)
library/core/src/option.rs

index 9b3b27b68a3cdd557d873f7644f9898d61ccc5b0..0022df4f65ff7cffd1a430d7afbe7b129ba2864d 100644 (file)
@@ -1726,7 +1726,7 @@ pub const fn cloned(self) -> Option<T>
     }
 }
 
-impl<T: Copy> Option<&mut T> {
+impl<T> Option<&mut T> {
     /// Maps an `Option<&mut T>` to an `Option<T>` by copying the contents of the
     /// option.
     ///
@@ -1742,15 +1742,16 @@ impl<T: Copy> Option<&mut T> {
     #[must_use = "`self` will be dropped if the result is not used"]
     #[stable(feature = "copied", since = "1.35.0")]
     #[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
-    pub const fn copied(self) -> Option<T> {
+    pub const fn copied(self) -> Option<T>
+    where
+        T: Copy,
+    {
         match self {
             Some(&mut t) => Some(t),
             None => None,
         }
     }
-}
 
-impl<T: Clone> Option<&mut T> {
     /// Maps an `Option<&mut T>` to an `Option<T>` by cloning the contents of the
     /// option.
     ///