Implement Params for Arc<P: Params>
This is useful for partial generic UIs.
This commit is contained in:
parent
278ae227a7
commit
dc97fb1019
|
@ -1,6 +1,7 @@
|
||||||
//! Implementation details for the parameter management.
|
//! Implementation details for the parameter management.
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use super::{Param, ParamFlags, ParamMut};
|
use super::{Param, ParamFlags, ParamMut};
|
||||||
|
|
||||||
|
@ -95,6 +96,21 @@ pub unsafe trait Params: 'static + Send + Sync {
|
||||||
fn deserialize_fields(&self, serialized: &BTreeMap<String, String>) {}
|
fn deserialize_fields(&self, serialized: &BTreeMap<String, String>) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This may be useful when building generic UIs using nested `Params` objects.
|
||||||
|
unsafe impl<P: Params> Params for Arc<P> {
|
||||||
|
fn param_map(&self) -> Vec<(String, ParamPtr, String)> {
|
||||||
|
self.as_ref().param_map()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_fields(&self) -> BTreeMap<String, String> {
|
||||||
|
self.as_ref().serialize_fields()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn deserialize_fields(&self, serialized: &BTreeMap<String, String>) {
|
||||||
|
self.as_ref().deserialize_fields(serialized)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Internal pointers to parameters. This is an implementation detail used by the wrappers for type
|
/// Internal pointers to parameters. This is an implementation detail used by the wrappers for type
|
||||||
/// erasure.
|
/// erasure.
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
|
||||||
|
|
Loading…
Reference in a new issue