You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently associated-derive just derives an implementation for Associated, but due to a language limitation trait methods cannot be const fn, which means the user cannot use .get_associated() to initialise a const.
One proposed solution is to optionally support generating a non-trait method on the enum which can then be const fn. In order to do so, the user should be able to supply a name for it to avoid name collision, but maybe default to get_associated. The macro will have to check that only #[assoc_const] variant attributes were used as #[assoc] wouldn't always work as it allows non-const expressions.
Currently
associated-derive
just derives an implementation forAssociated
, but due to a language limitation trait methods cannot beconst fn
, which means the user cannot use.get_associated()
to initialise a const.One proposed solution is to optionally support generating a non-trait method on the enum which can then be
const fn
. In order to do so, the user should be able to supply a name for it to avoid name collision, but maybe default toget_associated
. The macro will have to check that only#[assoc_const]
variant attributes were used as#[assoc]
wouldn't always work as it allows non-const expressions.Issue discovered by a kind Rustacean on r/rust
The text was updated successfully, but these errors were encountered: