@@ -240,7 +240,7 @@ use crate::ops::{self, Deref};
240
240
///
241
241
/// [`Ok`]: enum.Result.html#variant.Ok
242
242
/// [`Err`]: enum.Result.html#variant.Err
243
- #[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash ) ]
243
+ #[ derive( Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash ) ]
244
244
#[ must_use = "this `Result` may be an `Err` variant, which should be handled" ]
245
245
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
246
246
pub enum Result < T , E > {
@@ -1003,6 +1003,27 @@ fn unwrap_failed<E: fmt::Debug>(msg: &str, error: E) -> ! {
1003
1003
// Trait implementations
1004
1004
/////////////////////////////////////////////////////////////////////////////
1005
1005
1006
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1007
+ impl < T : Clone , E : Clone > Clone for Result < T , E > {
1008
+ #[ inline]
1009
+ fn clone ( & self ) -> Self {
1010
+ match self {
1011
+ Ok ( x) => Ok ( x. clone ( ) ) ,
1012
+ Err ( x) => Err ( x. clone ( ) ) ,
1013
+ }
1014
+ }
1015
+
1016
+ #[ inline]
1017
+ fn clone_from ( & mut self , source : & Self ) {
1018
+ match ( self , source) {
1019
+ ( Ok ( to) , Ok ( from) ) => to. clone_from ( from) ,
1020
+ ( Err ( to) , Err ( from) ) => to. clone_from ( from) ,
1021
+ ( to, from) => * to = from. clone ( ) ,
1022
+ }
1023
+ }
1024
+ }
1025
+
1026
+
1006
1027
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1007
1028
impl < T , E > IntoIterator for Result < T , E > {
1008
1029
type Item = T ;
0 commit comments