Skip to content

Can't migrate away from Foo::KIND #1073

Answered by clux
JPFrancoia asked this question in Q&A
Discussion options

You must be logged in to vote

Ah, yeah, writing generics on top of kube's Resource traits is currently a little tricky with the associated type.

The key part that you are trying to interact with is this bit of the Resource trait.

If you were just calling this in a non-generic setting you'd be fine with just passing in an empty tuple as the generic associated type DynamicType (which is the right type for the static k8s-openapi types), but because you are writing a generic function, you are also trying to cover all possible resources (such as DynamicObject and Object in kube, or other Resource implementors).

Thus you need to constrain the DynamicType to the subset you want (i.e. where it is just the empty tuple). The wa…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by JPFrancoia
Comment options

You must be logged in to vote
2 replies
@clux
Comment options

@JPFrancoia
Comment options

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