]> git.lizzy.rs Git - rust.git/commitdiff
Explicitly impl Clone for RWArc
authorKevin Ballard <kevin@sb.org>
Thu, 1 Aug 2013 22:02:03 +0000 (15:02 -0700)
committerDaniel Micay <danielmicay@gmail.com>
Sat, 3 Aug 2013 07:17:07 +0000 (03:17 -0400)
RWArc had a clone() method, but it was part of impl RWArc instead of
an implementation of Clone.

Stick with the explicit implementation instead of deriving Clone so we
can have a docstring.

Fixes #8052.

src/libextra/arc.rs

index 3aa77577fb2e43eba5ebce98e8a700f0f55067d6..af69997f02e8d9a70de872b58cc93ccfe68c1989 100644 (file)
@@ -140,14 +140,14 @@ pub fn unwrap(self) -> T {
     }
 }
 
-/**
- * Duplicate an atomically reference counted wrapper.
- *
- * The resulting two `arc` objects will point to the same underlying data
- * object. However, one of the `arc` objects can be sent to another task,
- * allowing them to share the underlying data.
- */
 impl<T:Freeze + Send> Clone for Arc<T> {
+    /**
+    * Duplicate an atomically reference counted wrapper.
+    *
+    * The resulting two `arc` objects will point to the same underlying data
+    * object. However, one of the `arc` objects can be sent to another task,
+    * allowing them to share the underlying data.
+    */
     fn clone(&self) -> Arc<T> {
         Arc { x: self.x.clone() }
     }
@@ -164,7 +164,7 @@ struct MutexArc<T> { priv x: UnsafeAtomicRcBox<MutexArcInner<T>> }
 
 
 impl<T:Send> Clone for MutexArc<T> {
-    /// Duplicate a mutex-protected Arc, as arc::clone.
+    /// Duplicate a mutex-protected Arc. See arc::clone for more details.
     fn clone(&self) -> MutexArc<T> {
         // NB: Cloning the underlying mutex is not necessary. Its reference
         // count would be exactly the same as the shared state's.
@@ -312,12 +312,10 @@ struct RWArc<T> {
     priv x: UnsafeAtomicRcBox<RWArcInner<T>>,
 }
 
-impl<T:Freeze + Send> RWArc<T> {
-    /// Duplicate a rwlock-protected Arc, as arc::clone.
-    pub fn clone(&self) -> RWArc<T> {
-        RWArc {
-            x: self.x.clone(),
-        }
+impl<T:Freeze + Send> Clone for RWArc<T> {
+    /// Duplicate a rwlock-protected Arc. See arc::clone for more details.
+    fn clone(&self) -> RWArc<T> {
+        RWArc { x: self.x.clone() }
     }
 
 }