Skip to content

Removing priv as a keyword #8122

Closed
Closed
@alexcrichton

Description

@alexcrichton

Now that you can't really put pub at the top-level of things like impl/extern/trait, you don't need the priv keyword to control method visibility of various items because they're all private by default.

pros:

  • I think that this would really simplify public/private because there's one and only one rule: private by default, public if you flag it
  • one less keyword!

difficulties:

  • Right now this is the only way to make struct fields private. I personally believe that private-by-default for struct fields isn't that bad of an idea, and if this were the only thing blocking removing priv I'd vote to remove it.

cons:

  • Enum variants can currently be tagged as priv, and if we removed priv there would be no way to make half the enum variants public and half private. In theory pub enum makes everything public and you could otherwise write pub on each variant, but the type name would still then have to be public and if it didn't have pub in front of it it wouldn't really make sense
  • Private-by-default for structs is kind of annoying sometimes.

What do others think about this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions