From dc97fb10193db88cdce938e080042a5c26580b11 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 23 Jul 2022 18:12:02 +0200 Subject: [PATCH] Implement Params for Arc This is useful for partial generic UIs. --- src/param/internals.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/param/internals.rs b/src/param/internals.rs index 2a47c4d0..a28365c2 100644 --- a/src/param/internals.rs +++ b/src/param/internals.rs @@ -1,6 +1,7 @@ //! Implementation details for the parameter management. use std::collections::BTreeMap; +use std::sync::Arc; use super::{Param, ParamFlags, ParamMut}; @@ -95,6 +96,21 @@ pub unsafe trait Params: 'static + Send + Sync { fn deserialize_fields(&self, serialized: &BTreeMap) {} } +/// This may be useful when building generic UIs using nested `Params` objects. +unsafe impl Params for Arc

{ + fn param_map(&self) -> Vec<(String, ParamPtr, String)> { + self.as_ref().param_map() + } + + fn serialize_fields(&self) -> BTreeMap { + self.as_ref().serialize_fields() + } + + fn deserialize_fields(&self, serialized: &BTreeMap) { + self.as_ref().deserialize_fields(serialized) + } +} + /// Internal pointers to parameters. This is an implementation detail used by the wrappers for type /// erasure. #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]