#[derive(Clone)] pub(crate) struct AnyValue {
inner: std::sync::Arc<dyn std::any::Any + Send + Sync + 'static>, // While we can extract `TypeId` from `inner`, the debug repr is of a number, so let's track // the type_name in debug builds.
id: AnyValueId,
}
impl AnyValue { pub(crate) fn new<V: std::any::Any + Clone + Send + Sync + 'static>(inner: V) -> Self { let id = AnyValueId::of::<V>(); let inner = std::sync::Arc::new(inner); Self { inner, id }
}
pub(crate) fn downcast_into<T: std::any::Any + Clone + Send + Sync>(self) -> Result<T, Self> { let id = self.id; let value =
ok!(std::sync::Arc::downcast::<T>(self.inner).map_err(|inner| Self { inner, id })); let value = std::sync::Arc::try_unwrap(value).unwrap_or_else(|arc| (*arc).clone());
Ok(value)
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.