@@ -1493,7 +1493,7 @@ impl<T, E> Result<T, E> {
1493
1493
}
1494
1494
}
1495
1495
1496
- impl < T : Copy , E > Result < & T , E > {
1496
+ impl < T , E > Result < & T , E > {
1497
1497
/// Maps a `Result<&T, E>` to a `Result<T, E>` by copying the contents of the
1498
1498
/// `Ok` part.
1499
1499
///
@@ -1508,9 +1508,33 @@ impl<T: Copy, E> Result<&T, E> {
1508
1508
/// assert_eq!(copied, Ok(12));
1509
1509
/// ```
1510
1510
#[ unstable( feature = "result_copied" , reason = "newly added" , issue = "63168" ) ]
1511
- pub fn copied ( self ) -> Result < T , E > {
1511
+ pub fn copied ( self ) -> Result < T , E >
1512
+ where
1513
+ T : Copy ,
1514
+ {
1512
1515
self . map ( |& t| t)
1513
1516
}
1517
+
1518
+ /// Maps a `Result<&T, E>` to a `Result<T, E>` by cloning the contents of the
1519
+ /// `Ok` part.
1520
+ ///
1521
+ /// # Examples
1522
+ ///
1523
+ /// ```
1524
+ /// #![feature(result_cloned)]
1525
+ /// let val = 12;
1526
+ /// let x: Result<&i32, i32> = Ok(&val);
1527
+ /// assert_eq!(x, Ok(&12));
1528
+ /// let cloned = x.cloned();
1529
+ /// assert_eq!(cloned, Ok(12));
1530
+ /// ```
1531
+ #[ unstable( feature = "result_cloned" , reason = "newly added" , issue = "63168" ) ]
1532
+ pub fn cloned ( self ) -> Result < T , E >
1533
+ where
1534
+ T : Clone ,
1535
+ {
1536
+ self . map ( |t| t. clone ( ) )
1537
+ }
1514
1538
}
1515
1539
1516
1540
impl < T : Copy , E > Result < & mut T , E > {
@@ -1533,26 +1557,6 @@ impl<T: Copy, E> Result<&mut T, E> {
1533
1557
}
1534
1558
}
1535
1559
1536
- impl < T : Clone , E > Result < & T , E > {
1537
- /// Maps a `Result<&T, E>` to a `Result<T, E>` by cloning the contents of the
1538
- /// `Ok` part.
1539
- ///
1540
- /// # Examples
1541
- ///
1542
- /// ```
1543
- /// #![feature(result_cloned)]
1544
- /// let val = 12;
1545
- /// let x: Result<&i32, i32> = Ok(&val);
1546
- /// assert_eq!(x, Ok(&12));
1547
- /// let cloned = x.cloned();
1548
- /// assert_eq!(cloned, Ok(12));
1549
- /// ```
1550
- #[ unstable( feature = "result_cloned" , reason = "newly added" , issue = "63168" ) ]
1551
- pub fn cloned ( self ) -> Result < T , E > {
1552
- self . map ( |t| t. clone ( ) )
1553
- }
1554
- }
1555
-
1556
1560
impl < T : Clone , E > Result < & mut T , E > {
1557
1561
/// Maps a `Result<&mut T, E>` to a `Result<T, E>` by cloning the contents of the
1558
1562
/// `Ok` part.
0 commit comments