<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello everyone !<div class=""><br class=""></div><div class="">I am currently writing a project where I would like to do something similar to this:</div><div class=""><br class=""></div><div class=""><font color="#606060" class=""><b class="">protocol&nbsp;ProtocolA {<br class="">&nbsp; &nbsp;&nbsp;associatedtype&nbsp;U<br class="">&nbsp; &nbsp;&nbsp;var&nbsp;someVariable : U {&nbsp;get&nbsp;set&nbsp;}<br class="">&nbsp; &nbsp;&nbsp;func&nbsp;someFunction(_&nbsp;x:U) -&gt; U<br class="">}<br class=""><br class="">class&nbsp;SomeClass&lt;T&gt; {<br class="">&nbsp; &nbsp;&nbsp;var&nbsp;someProperty :&nbsp;ProtocolA&nbsp;where&nbsp;ProtocolA.U == T<br class="">}</b></font></div><div class=""><br class=""></div><div class="">But this isn't possible so I had to implement it as a generic class:</div><div class="">class NewClass&lt;U&gt; { ... }</div><div class=""><br class=""></div><div class="">And now I am using it like this:</div><div class="">class SomeClass&lt;T&gt; {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var someProperty: NewClass&lt;T&gt;</div><div class="">}</div><div class=""><br class=""></div><div class="">The issue here is that protocols aren't used any more with this approach, and in my case there is no "default" implementation of <i class="">myFunction</i>, so protocols where really useful!!</div><div class=""><br class=""></div><div class="">Is there a better way to do that in the current Swift version?</div><div class=""><br class=""></div><div class="">Today, I came across the proposal SE-0142 (Permit where clauses to constrain associated&nbsp;types), but this only seems to apply inside of protocols, what is your opinion about having similar mechanisms in classes and structs ?</div><div class=""><br class=""></div><div class="">Thank you!</div><div class=""><br class=""></div><div class="">Trevör</div></body></html>