Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_reflect/src/serde/de/registration_utils.rs
6600 views
1
use crate::{serde::de::error_utils::make_custom_error, Type, TypeRegistration, TypeRegistry};
2
use serde::de::Error;
3
4
/// Attempts to find the [`TypeRegistration`] for a given [type].
5
///
6
/// [type]: Type
7
pub(super) fn try_get_registration<E: Error>(
8
ty: Type,
9
registry: &TypeRegistry,
10
) -> Result<&TypeRegistration, E> {
11
let registration = registry.get(ty.id()).ok_or_else(|| {
12
make_custom_error(format_args!("no registration found for type `{ty:?}`"))
13
})?;
14
Ok(registration)
15
}
16
17