Extend the protocol to meet one of several limitations

I want to extend the protocol to satisfy one of several limitations. I know how to satisfy several constraints with (,), but that will fit all of them.

Example:

protocol Abc { ... } protocol xyz { ... } protocol my { ... } extenstion Abc where Self: xyz, Self: my { ... } 

I want Abc match xyz or my .

+5
source share
1 answer

I think you can use a common protocol for this:

 protocol Common { } protocol Abc { } protocol xyz: Common { } protocol my: Common { } extension Abc where Self: Common { } 
+1
source

Source: https://habr.com/ru/post/1246678/


All Articles