diff --git a/implementations/rust/preserves/src/value/repr.rs b/implementations/rust/preserves/src/value/repr.rs index b89abd6..ecb5a77 100644 --- a/implementations/rust/preserves/src/value/repr.rs +++ b/implementations/rust/preserves/src/value/repr.rs @@ -11,6 +11,7 @@ use std::marker::PhantomData; use std::ops::Index; use std::ops::IndexMut; use std::string::String; +use std::sync::Arc; use std::vec::Vec; pub use std::collections::BTreeSet as Set; @@ -25,6 +26,16 @@ pub trait Domain: Sized + Debug + Clone + Eq + Hash + Ord { fn as_preserves(&self) -> IOValue; } +impl Domain for Arc { + fn from_preserves(v: IOValue) -> IOResult { + Ok(Arc::new(D::from_preserves(v)?)) + } + + fn as_preserves(&self) -> IOValue { + D::as_preserves(self) + } +} + pub trait NestedValue: Sized + Debug + Clone + Eq + Hash + Ord { fn wrap(anns: Annotations, v: Value) -> Self; @@ -1046,8 +1057,6 @@ impl<'de, Dom: Domain> serde::Deserialize<'de> for RcValue { //--------------------------------------------------------------------------- -use std::sync::Arc; - #[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct ArcValue(Arc, D>>);