reference icon indicating copy to clipboard operation
reference copied to clipboard

Add const generic default restrictions

Open ehuss opened this issue 3 years ago • 0 comments

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: https://github.com/rust-lang/rust/pull/90207#issuecomment-958843546 and #1098.

ehuss avatar Feb 08 '22 04:02 ehuss