summaryrefslogtreecommitdiff
path: root/matrix-lang/src/value/gc.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--matrix-lang/src/value/gc.rs (renamed from matrix/src/gc.rs)22
1 files changed, 16 insertions, 6 deletions
diff --git a/matrix/src/gc.rs b/matrix-lang/src/value/gc.rs
index 7af020b..5ef8b80 100644
--- a/matrix/src/gc.rs
+++ b/matrix-lang/src/value/gc.rs
@@ -1,4 +1,5 @@
use std::{ops::{Index, IndexMut, Deref, DerefMut, Add, Sub, Mul}, marker::PhantomData, ptr::NonNull, fmt::{Debug, Display}};
+use crate::prelude::*;
pub struct Gc<T> {
ptr: NonNull<GcInner<T>>,
@@ -24,22 +25,31 @@ impl<T> Gc<T> {
}
impl <T: Clone> Gc<T> {
- pub fn clone_inside(&self) -> Self {
+ pub fn into_inner(self) -> T {
unsafe {
- let data = self.ptr.as_ref().data.clone();
- Self::new(data)
+ self.ptr.as_ref().data.clone()
}
}
- pub fn into_inner(self) -> T {
+ fn data(&self) -> T {
unsafe {
self.ptr.as_ref().data.clone()
}
}
+}
- fn data(&self) -> T {
+impl <T: ValueClone> ValueClone for Gc<T> {
+ fn deep_clone(&self) -> Self {
unsafe {
- self.ptr.as_ref().data.clone()
+ let data = self.ptr.as_ref().data.deep_clone();
+ Self::new(data)
+ }
+ }
+
+ fn shallow_clone(&self) -> Self {
+ unsafe {
+ let data = self.ptr.as_ref().data.shallow_clone();
+ Self::new(data)
}
}
}