fix list cloning not cloning inner values

this would allow mutating values
through a list passed by value,
but now it doesn't, which is
how it always should have been.
This commit is contained in:
Mark
2024-04-30 13:58:40 +02:00
parent 1554453eb9
commit 945e19e10a
6 changed files with 38 additions and 19 deletions

View File

@@ -7,7 +7,7 @@ use std::{
use super::{Data, MersData, MersType, Type};
#[derive(Debug, Clone)]
pub struct Reference(pub Arc<RwLock<Data>>, pub Type);
pub struct Reference(pub Arc<RwLock<Data>>);
impl MersData for Reference {
fn is_eq(&self, other: &dyn MersData) -> bool {
@@ -21,7 +21,7 @@ impl MersData for Reference {
Box::new(Clone::clone(self))
}
fn as_type(&self) -> Type {
Type::new(ReferenceT(self.1.clone()))
Type::new(ReferenceT(self.0.read().unwrap().get().as_type()))
}
fn as_any(&self) -> &dyn Any {
self