ability to ignore type uuid of generics in reflect proc-macro

This commit is contained in:
Dmitry Stepanov
2026-07-26 16:23:53 +03:00
parent eb620916be
commit 8363d35c0b
3 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -456,7 +456,7 @@ fn gen_impl(
};
let type_uuid_str = ty_args.type_uuid.as_str();
let type_uuid = if ty_args.generics.params.is_empty() {
let type_uuid = if ty_args.generics.params.is_empty() || ty_args.ignore_generics_type_uuid {
quote! { uuid!(#type_uuid_str) }
} else {
// Try to combine uuids from types and consts.
+3
View File
@@ -69,6 +69,9 @@ pub struct TypeArgs {
#[darling(default)]
pub clone_fn: Option<Path>,
#[darling(default)]
pub ignore_generics_type_uuid: bool,
pub type_uuid: String,
}
+7
View File
@@ -119,6 +119,9 @@ pub struct TypeInfo {
/// subtype for the `Type`.
/// - `#[reflect(type_uuid = "5989667c-ca43-46ca-b906-ae4319f659a5")]` - assigns a unique identifier
/// for the type. See the respective section below for more info.
/// - `#[reflect(ignore_generics_type_uuid)]` - prevents the proc-macro from combining the UUIDs of
/// generic arguments with the `type_uuid` of the type itself. Off by default (combines uuids by
/// default).
///
/// ### Direct vs Indirect Access
///
@@ -180,6 +183,10 @@ pub struct TypeInfo {
/// especially important in case of trait object serialization, where the UUID is used to link the
/// actual type with its representation in a serialized form.
///
/// By default, the proc-macro tries to combine the given UUID with the uuids of each generic type.
/// Which in its turn applies `Reflect` trait bound to each generic argument. If it is not desired
/// behavior, use `#[reflect(ignore_generics_type_uuid)]` option.
///
/// ## Additional Trait Bounds
///
/// `Reflect` restricted to types that implement `Debug` trait, this is needed to convert the actual value