@@ -145,7 +145,7 @@ use crate::pin::Pin;
145145// which basically means it must be `Option`.
146146
147147/// The `Option` type. See [the module level documentation](index.html) for more.
148- #[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash ) ]
148+ #[ derive( Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash ) ]
149149#[ stable( feature = "rust1" , since = "1.0.0" ) ]
150150pub enum Option < T > {
151151 /// No value
@@ -1040,6 +1040,25 @@ fn expect_failed(msg: &str) -> ! {
10401040// Trait implementations
10411041/////////////////////////////////////////////////////////////////////////////
10421042
1043+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1044+ impl < T : Clone > Clone for Option < T > {
1045+ #[ inline]
1046+ fn clone ( & self ) -> Self {
1047+ match self {
1048+ Some ( x) => Some ( x. clone ( ) ) ,
1049+ None => None ,
1050+ }
1051+ }
1052+
1053+ #[ inline]
1054+ fn clone_from ( & mut self , source : & Self ) {
1055+ match ( self , source) {
1056+ ( Some ( to) , Some ( from) ) => to. clone_from ( from) ,
1057+ ( to, from) => * to = from. clone ( ) ,
1058+ }
1059+ }
1060+ }
1061+
10431062#[ stable( feature = "rust1" , since = "1.0.0" ) ]
10441063impl < T > Default for Option < T > {
10451064 /// Returns [`None`][Option::None].
0 commit comments