diff --git a/interpreter/src/objects.rs b/interpreter/src/objects.rs index 56a8278..a84b07e 100644 --- a/interpreter/src/objects.rs +++ b/interpreter/src/objects.rs @@ -11,12 +11,11 @@ use std::cmp::Ordering; use std::collections::HashMap; use std::convert::{TryFrom, TryInto}; use std::fmt::{Display, Formatter}; -use std::rc::Rc; use std::sync::Arc; #[derive(Debug, PartialEq, Clone)] pub struct Map { - pub map: Rc>, + pub map: Arc>, } impl PartialOrd for Map { @@ -126,7 +125,7 @@ impl, V: Into> From> for Map { new_map.insert(k.into(), v.into()); } Map { - map: Rc::new(new_map), + map: Arc::new(new_map), } } } @@ -171,6 +170,9 @@ pub enum Value { Null, } +unsafe impl Sync for Value {} +unsafe impl Send for Value {} + pub enum ValueType { List, Map, @@ -516,7 +518,10 @@ impl<'a> Value { let value = Value::resolve(v, ctx)?; map.insert(key, value); } - Value::Map(Map { map: Rc::from(map) }).into() + Value::Map(Map { + map: Arc::from(map), + }) + .into() } Expression::Ident(name) => { if ctx.has_function(&***name) { @@ -686,7 +691,7 @@ impl ops::Add for Value { for (k, v) in r.map.iter() { new.insert(k.clone(), v.clone()); } - Value::Map(Map { map: Rc::new(new) }) + Value::Map(Map { map: Arc::new(new) }) } (Value::Duration(l), Value::Duration(r)) => Value::Duration(l + r), (Value::Timestamp(l), Value::Duration(r)) => Value::Timestamp(l + r),