Skip to content

Commit f893e0c

Browse files
committed
Try to clarify some of the alternatives a bit
1 parent fb94bf1 commit f893e0c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

proposals/NNNN-suppressed-associated-types.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,11 @@ protocol Container: ~Copyable, ~Escapable {
787787
788788
default Element: Copyable, Element: Escapable
789789
}
790+
791+
// defaults to 'where Element: Copyable & Escapable' only.
792+
//
793+
// Self and Self.BorrowingIterator remain ~Copyable & ~Escapable
794+
extension Container {}
790795
```
791796
792797
This might also serve as a way for a protocol to opt generic parameters *out*
@@ -816,9 +821,11 @@ extension Container without Escaping {}
816821
817822
extension Container without Copying, Escaping {} // fully unconstrained in -version
818823
819-
// For generic signatures in other positions, we could have syntax
820-
// that allows you to refer to constraintsets like a member:
821-
func f<T: Container, V: Container>() without T: Container.Copying {}
824+
func f<T: Container>() without T: Container.Copying {}
825+
826+
// We could have syntax that allows you to refer to constraintsets like a member,
827+
// to opt out a generic type parameter from multiple constrainsets:
828+
func g<T: Container & P>() without T: Container.Copying or T: P.Copying {}
822829
```
823830
824831
This functionality might also be used for future evolution. Let’s say we add a third suppressable protocol Runcible in the future, and we want to generalize Container to allow for `~Runcible` elements. We can suppress the Runcible requirement on Self and `Self.Element` along with a new default constraint set that reinstates the requirements for existing code. Existing code would continue to apply all of the default sets, and doesn’t know about the new constraint set yet, so would not suppress the newly lifted requirements:

0 commit comments

Comments
 (0)