summaryrefslogtreecommitdiff
path: root/rust/src/rc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/rc.rs')
-rw-r--r--rust/src/rc.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/rust/src/rc.rs b/rust/src/rc.rs
index b21b7b94..a65403e2 100644
--- a/rust/src/rc.rs
+++ b/rust/src/rc.rs
@@ -135,6 +135,15 @@ impl<'a, T> Guard<'a, T> {
}
}
+impl<'a, T> Guard<'a, T>
+where
+ T: RefCountable,
+{
+ pub fn clone(&self) -> Ref<T> {
+ unsafe { <T as RefCountable>::inc_ref(&self.contents) }
+ }
+}
+
impl<'a, T> AsRef<T> for Guard<'a, T> {
fn as_ref(&self) -> &T {
&self.contents