summaryrefslogtreecommitdiff
path: root/matrix-lang/src/value/gc.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-02-29 17:04:28 -0500
committerFreya Murphy <freya@freyacat.org>2024-02-29 17:04:28 -0500
commit5d2747e26f51cc2344a6bd95f93457248fdfebd8 (patch)
tree8755b4068166c3854d26817683ce438a771ab319 /matrix-lang/src/value/gc.rs
parentmore mat, sys, and os stdlib functions, better matrix printing, other fixes (diff)
downloadmatrix-5d2747e26f51cc2344a6bd95f93457248fdfebd8.tar.gz
matrix-5d2747e26f51cc2344a6bd95f93457248fdfebd8.tar.bz2
matrix-5d2747e26f51cc2344a6bd95f93457248fdfebd8.zip
fin prob
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)
}
}
}