Skip to content

Can't Derive ToVariant on generic type with constraint #957

Open
@astrale-sharp

Description

@astrale-sharp

Hi !
I'm trying to get this to compile :

#[derive(Debug, Clone, ToVariant)]
pub enum WorldChange<T: Entity> {
    EntityMoved {
        id: EntityId,
        from: Position,
        to: Position,
    },
    EntitySentMessage {
        from: EntityId,
        to: EntityId,
        msg: T::Message,
    },
    EntityStateChanged {
        id: EntityId,
        change: T::EntityChange,
    },
    EntityPlaced(EntityId, Position),
    EntityUnplaced(EntityId),
}

but it complains this enum takes 1 generic argument but 0 generic arguments were supplied expected 1 generic argument.

Note that it doesn't complain for MyStruct, but it complains for any constraint MyStruct or MyStruct
it doesn't matter as well if T::Message impl ToVariant or not (which it does)

It would be nice to be able to constrain the type because my only other option is to impl ToVariant by myself which is not ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugc: exportComponent: export (mod export, derive)

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions