Skip to content

Arbitrary discriminants with map = "compact" #81

@ronnodas

Description

@ronnodas

The Mapping Options section in the documentation for the derive macro says:

#[enumset(map = "compact")] maps each enum variant to an unspecified bit in the set. This allows the library to use less memory than it may otherwise and allows any discrminator [sic] values to be used without issue.

But I tried

#[derive(EnumSetType)]
#[enumset(map = "compact")]
#[repr(u8)]
pub enum Cased {
    CapitalA = b'A',
    ...
}

And got the error "Expression not supported by enumset.", even though this satisfies the Limitations section in the same docs. It seems negative discriminants aren't possible either (with a more cryptic error "expected Expr" when the #[enumset(map = "compact")] line is included), but at least this is called out in the limitations.

Is it possible to completely ignore the discriminants with the map = "compact" option? If not, the documentation should be updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions