~const Trait
will definitely be more common in libraries, but every use terminates with a const Trait
use at some point, because it needs to be actually used in a const (type or associated) context at some point.
It's a similar argument imho to whether cargo new
should default to --lib
or --bin
; there's clearly more libs on crates-io than bins, but for every lib there should be more than one bin using it.
The same logic to ~const Trait
: for every ~const
API, there's some API that uses it as const
(otherwise it'd not exist and be ~const
), and likely more than one.
The wrinkle here is of course transitivity (you can have libs only used by other libs, which are then used by a bin; you can have ~const
APIs only used by other ~const
APIs which are then used by a const context). However, the law of big numbers suggests that in the asymptote we will have more terminal cases (bin, const
) than nonterminal cases (lib, ~const
).
There's another wrinkle specific to ~const
, though: not every const
context needs to explicitly write const Trait
. If concrete types are used rather than generics, we have a terminal case using const Trait
without ever writing const Trait
in the source code.
Either way, though, we do need a way to write both ~const Trait
, const Trait
, and ?const Trait
. This proposal gives the current "I don't care" (: ?const Trait
) the default : Trait
, the "always" to : const Trait
, and the conditional to : ~const Trait
. Any counterproposal needs to provide for all three to be writable.
Personally, I'm happy to get it implemented with any syntax, because the semantics and implementation will have some cooking to be done before stabilization. I expect ~const
to be the .await
discussion of const evaluation, and happily await the relevant teams' discussion and decision in the matter.