about summary refs log tree commit diff
path: root/src/libstd/managed.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-10-17 21:13:56 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-10-17 21:14:38 -0700
commit82f5f65076e604ec70a6e09cdbe8dddb8b3b7c44 (patch)
tree2c7016ccf67bb995f630ae1620c072fe4f3e764b /src/libstd/managed.rs
parentd8d1b8f8be250b9e19bb70aa0968c1b4a4aec2f8 (diff)
downloadrust-82f5f65076e604ec70a6e09cdbe8dddb8b3b7c44.tar.gz
rust-82f5f65076e604ec70a6e09cdbe8dddb8b3b7c44.zip
Move sys::refcount to managed::refcount
More progress on #2240
Diffstat (limited to 'src/libstd/managed.rs')
-rw-r--r--src/libstd/managed.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstd/managed.rs b/src/libstd/managed.rs
index 57230b2fd24..a27c8aa4a76 100644
--- a/src/libstd/managed.rs
+++ b/src/libstd/managed.rs
@@ -17,6 +17,13 @@ use ptr::to_unsafe_ptr;
 pub static RC_MANAGED_UNIQUE : uint = (-2) as uint;
 pub static RC_IMMORTAL : uint = 0x77777777;
 
+/// Returns the refcount of a shared box (as just before calling this)
+#[inline]
+pub fn refcount<T>(t: @T) -> uint {
+    use unstable::raw::Repr;
+    unsafe { (*t.repr()).ref_count }
+}
+
 /// Determine if two shared boxes point to the same object
 #[inline]
 pub fn ptr_eq<T>(a: @T, b: @T) -> bool {