Skip to content

πŸ’‘ [REQUEST] - Generate PartialEq for EnumsΒ #437

@SteMak

Description

@SteMak

Summary

Automatically derive PartialEq for enums in generated types.rs

Lack of PartialEq limits account storage validation

Basic Example

// types.rs

/// Custom enum: Role
#[derive(Debug, BorshDeserialize, BorshSerialize, Clone, /* auto-derive here */ PartialEq)]
pub enum Role {
    Admin,
    User,
}
// test_fuzz.rs

    let account = self
        .trident
        .get_account_with_type::<Account>(&address, 8)
        .unwrap();

    // The resolved issue is:
    //   binary operation `==` cannot be applied to type `types::Role`
    //   consider annotating `types::Role` with `#[derive(PartialEq)]`
    assert!(account.role == Role::User);

Drawbacks

Complex enums based on fields which do not implement PartialEq would not allow this

Unresolved questions

No response

Implementation PR

No response

Reference Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions