Skip to content

Commit 75155cd

Browse files
lilyballthestinger
authored andcommitted
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.
1 parent 1992765 commit 75155cd

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/libextra/arc.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ impl<T:Freeze+Send> Arc<T> {
140140
}
141141
}
142142

143-
/**
144-
* Duplicate an atomically reference counted wrapper.
145-
*
146-
* The resulting two `arc` objects will point to the same underlying data
147-
* object. However, one of the `arc` objects can be sent to another task,
148-
* allowing them to share the underlying data.
149-
*/
150143
impl<T:Freeze + Send> Clone for Arc<T> {
144+
/**
145+
* Duplicate an atomically reference counted wrapper.
146+
*
147+
* The resulting two `arc` objects will point to the same underlying data
148+
* object. However, one of the `arc` objects can be sent to another task,
149+
* allowing them to share the underlying data.
150+
*/
151151
fn clone(&self) -> Arc<T> {
152152
Arc { x: self.x.clone() }
153153
}
@@ -164,7 +164,7 @@ struct MutexArc<T> { priv x: UnsafeAtomicRcBox<MutexArcInner<T>> }
164164

165165

166166
impl<T:Send> Clone for MutexArc<T> {
167-
/// Duplicate a mutex-protected Arc, as arc::clone.
167+
/// Duplicate a mutex-protected Arc. See arc::clone for more details.
168168
fn clone(&self) -> MutexArc<T> {
169169
// NB: Cloning the underlying mutex is not necessary. Its reference
170170
// count would be exactly the same as the shared state's.
@@ -312,12 +312,10 @@ struct RWArc<T> {
312312
priv x: UnsafeAtomicRcBox<RWArcInner<T>>,
313313
}
314314
315-
impl<T:Freeze + Send> RWArc<T> {
316-
/// Duplicate a rwlock-protected Arc, as arc::clone.
317-
pub fn clone(&self) -> RWArc<T> {
318-
RWArc {
319-
x: self.x.clone(),
320-
}
315+
impl<T:Freeze + Send> Clone for RWArc<T> {
316+
/// Duplicate a rwlock-protected Arc. See arc::clone for more details.
317+
fn clone(&self) -> RWArc<T> {
318+
RWArc { x: self.x.clone() }
321319
}
322320
323321
}

0 commit comments

Comments
 (0)