@@ -145,7 +145,7 @@ use crate::pin::Pin;
145
145
// which basically means it must be `Option`.
146
146
147
147
/// 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 ) ]
149
149
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
150
150
pub enum Option < T > {
151
151
/// No value
@@ -1040,6 +1040,25 @@ fn expect_failed(msg: &str) -> ! {
1040
1040
// Trait implementations
1041
1041
/////////////////////////////////////////////////////////////////////////////
1042
1042
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
+
1043
1062
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1044
1063
impl < T > Default for Option < T > {
1045
1064
/// Returns [`None`][Option::None].
0 commit comments