Skip to content

Feature request: Bring back newtypes instead of type aliases #1393

@poliorcetics

Description

@poliorcetics

Motivation

Before 0.29, Foundation::HWND and friends were defined as wrappers around a usize/isize or something else. It made code a little verbose but it was very easy to differentiate values and to see exactly what was what.

This is now impossible and can easily lead to confusion when passing defaults/values defined far away.

For example, I liked to use Type::default() or HWND(0) because it made the type very clear, even in code reviews where type hint are hover docs are missing.

Drawbacks

Verbose, probably worse compile times.

Rationale and alternatives

Keep current format.

Additional context

One thing that was missing was Binary operations, like Or/And/Xor for such types. Since those are now type aliases, that makes them available by default, which is nice. Maybe find a way to have both ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions