We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d052912 + 6a11e17 commit a1b25f2Copy full SHA for a1b25f2
src/libstd/managed.rs
@@ -21,7 +21,7 @@ pub static RC_IMMORTAL : uint = 0x77777777;
21
#[inline]
22
pub fn refcount<T>(t: @T) -> uint {
23
use unstable::raw::Repr;
24
- unsafe { (*t.repr()).ref_count }
+ unsafe { (*t.repr()).ref_count - 1 }
25
}
26
27
/// Determine if two shared boxes point to the same object
@@ -110,3 +110,14 @@ fn test() {
110
assert!((!ptr_eq::<int>(x, y)));
111
assert!((!ptr_eq::<int>(y, x)));
112
113
+
114
+#[test]
115
+fn refcount_test() {
116
+ use clone::Clone;
117
118
+ let x = @3;
119
+ assert_eq!(refcount(x), 1);
120
+ let y = x.clone();
121
+ assert_eq!(refcount(x), 2);
122
+ assert_eq!(refcount(y), 2);
123
+}
0 commit comments