Skip to content

Add const generic default restrictions #1159

@ehuss

Description

@ehuss

With const generic defaults stabilized (#90207), the reference should talk more about what the restrictions are.

  • What are valid expressions for the default? I assume it has to be a constant expression, are there other restrictions?
  • Presumably this is a const context, so I think "default const parameters" should be added to that list.
  • Restrictions on the type of the default expression. I believe it must be the same type as the declaration, but can there be any coercion?
  • Const defaults are only allowed on struct/enum/type/trait, but not fn or …

Are there other details about const generic defaults that can be added?
Note: default generic parameters are not documented at all. That is a separate issue (#24). That would also be great to complete, but I think can be done somewhat separately of this issue.

See also stabilization report: rust-lang/rust#90207 (comment)
and #1098.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions