Skip to content

Trait sugar syntax for maker trait and implementing the same maker trait for multiple type #3732

Open

Description

@Thomas-Mewily

Hello there, here is just a personal suggestion to keep the consistency between declaring a empty struct / marker trait, nothings really important but anyway ^^

struct Empty;   // ok
struct Empty {} // ok

trait SignedInteger;   // currently not ok 
trait SignedInteger {} // ok

impl SignedInteger for i8;   // currently not ok
impl SignedInteger for i8 {} // ok

Also, sometime implementing the same maker trait for multiples types can be helpful (instead of using macro) :

impl SignedInteger for i8, i16, i32, i64, isize;   // currently not ok
impl SignedInteger for i8, i16, i32, i64, isize {} // currently not ok

Activity

  1. kennytm commented on Nov 26, 2024

    @kennytm
    Member

    consistency between declaring a empty struct / marker trait

    struct Empty; and struct Empty {} are not equivalent. The former also allows you to create an instance like let x = Empty; which is not possible for the latter.

    So there is no "consistency", and it is not an applicable rationale here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions