Skip to content

How to make a dependency of a protocol #25

Discussion options

You must be logged in to vote

Hey @kakhaberikiknadze! If you want to use protocols, you should probably use existentials (any) all the way. The performance impact is something that is often mentioned, but it may be very marginal in your situation (if not all).

Another solution would be to redesign your dependency to not use protocols. See for example this section of the documentation, which is functionally equivalent to erasing your protocol. You can totally imagine having a generic init to this struct, to easily wrap your existing StyleProviding types.

There are other solutions, but this is likely the road I would take. Can you tell us more about MyGenericStruct generic requirement? Does StylerProviding have an assoc…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kakhaberikiknadze
Comment options

@tgrapperon
Comment options

@kakhaberikiknadze
Comment options

Answer selected by kakhaberikiknadze
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants