Skip to content

Commit efd965c

Browse files
author
Olivier Saut
committed
Add the get method to std::arc::ARC
1 parent 20033c9 commit efd965c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libstd/arc.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ pub fn get<'a, T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
9696
unsafe { &*rc.x.get_immut() }
9797
}
9898

99+
impl<T: Const + Owned> ARC<T> {
100+
pub fn get<'a>(&'a self) -> &'a T {
101+
get(self)
102+
}
103+
}
99104
/**
100105
* Duplicate an atomically reference counted wrapper.
101106
*
@@ -507,7 +512,8 @@ mod tests {
507512
let c = p.recv();
508513
c.send(arc::clone(&arc_v));
509514

510-
assert!((*arc::get(&arc_v))[2] == 3);
515+
assert_eq!((*arc::get(&arc_v))[2], 3);
516+
assert_eq!(arc_v.get()[4], 5);
511517

512518
info!(arc_v);
513519
}

0 commit comments

Comments
 (0)