-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Constraints for generics (generics details 3) (#818)
This proposal describes `where` clauses that can add constraints on a type-of-type, for example define restrictions on its associated types. Example: ``` fn FindFirstPrime[T:! Container where .Element = i32] (c: T) -> Optional(i32) { // The elements of `c` have type `T.Element`, which is `i32`. ... } fn PrintContainer[T:! Container where .Element is Printable](c: T) { // The type of the elements of `c` is not known, but we do know // that type satisfies the `Printable` interface. ... } ``` Some other constraints, such as `Sized` are defined as type-of-types directly, possibly parameterized. Co-authored-by: Richard Smith <richard@metafoo.co.uk> Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
- Loading branch information
1 parent
05efb27
commit 89a829b
Showing
7 changed files
with
2,042 additions
and
84 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.