about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-08-01 15:02:03 -0700
committerDaniel Micay <danielmicay@gmail.com>2013-08-03 03:17:07 -0400
commit75155cd1b0c134056e86addbbf9097a26fe6a1f5 (patch)
tree1737e4d87a3c916f2a454d2d4853a0d8c7c534c9
parent1992765dd3b689fa62764eba99ed0610654b070f (diff)
downloadrust-75155cd1b0c134056e86addbbf9097a26fe6a1f5.tar.gz
rust-75155cd1b0c134056e86addbbf9097a26fe6a1f5.zip
Explicitly impl Clone for RWArc
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.
-rw-r--r--src/libextra/arc.rs26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs
index 3aa77577fb2..af69997f02e 100644
--- a/src/libextra/arc.rs
+++ b/src/libextra/arc.rs
@@ -140,14 +140,14 @@ impl<T:Freeze+Send> 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.
- */
 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() }
     }
 
 }