-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
The current syntax for denoting a dynamically-sized type parameter is Sized? T. This acts as a way of removing the implicit Sized bound that all type parameters have by default. This has the nice advantage of being open to adding other default trait bounds in the future with a similar syntax for opting out. (Drop could be one: uninitialised pointers are not able to be dropped, but everything else is.) However, to me it seems inconsistent with the syntax for normal bounds, which come after the type parameter name. It also can’t be used in a where clause, unlike everything else applied to type parameters. Because DST never went through a proper RFC, and the syntax for DSTs has changed twice, it would be nice if we could get some proper feedback on want the syntax should actually be. I personally prefer T: Sized?, but perhaps other people will have other ideas.
For the record, here are the different syntaxes we’ve gone through:
unsized T: the original, obvious syntaxtype T: there was a blog post on this- Motivation: Sized ∪ Unsized = All types
Sized? T: the current syntax- Motivation: Makes the implicit
Sizedbound normally present in all type parameters optional
- Motivation: Makes the implicit