Skip to content

impl From<FlagSet<F>> for F::Type? #20

@EndilWayfare

Description

@EndilWayfare

Obviously, from a pure-Rust standpoint, I think it makes sense to stay in the typecheck-guaranteed land of FlagSet: just think in terms of "a set of flags", and "it's a bitfield" is just an implementation detail. If you're converting to an integer, you better have a good reason.

I'm coming from the interop/FFI side of things, where I really dislike the type-looseness of winapi's "ayyy ENUM is just a bunch of constants and a type alias. Shove a STGMOVE into a VARENUM? Sure, that's allowed, actually defined, though semantically absurd. Shove a VARENUM into a STGMOVE? That's undefined, but we're not gonna stop you lmao". I can't imagine seriously going back to a language without proper sum types. The "good reason" for casting to integer, though, is "that's what the foreign API expects".

Sure, the bits method exists, but I think there's something to be said for the universally understood semantics of From/Into. Going from FlagSet<F> -> F::Type is infallible, so I can't think of a good reason off the top of my head not to impl.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions