Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Mashal/Unmarshal having only a parametrized interface #563

Open
aalireza opened this issue Jul 7, 2024 · 1 comment
Open

feature: Mashal/Unmarshal having only a parametrized interface #563

aalireza opened this issue Jul 7, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@aalireza
Copy link

aalireza commented Jul 7, 2024

Is your feature request related to a problem? Please describe.

I have interfaces like this:

type Scalar[T any] interface {
    Add(rhs Scalar[T]) T
}

I want to directly marshal and unmarshal having only the interface itself. If this interface wasn't parametrized, then I could have defined an encoder/decoder with a TagSet where I would add the concrete types of Scalar. I can't do that when the interface (and by extension, the concrete type that's implementing it) is parametrized as I have to fill out the concrete type's parameters at TagSet.Add time without knowing what they are.

Describe the solution you'd like
To directly marshal an unmarshal, having only the parametrized interface itself.

Describe alternatives you've considered
N/A

Additional context
N/A

@fxamacker
Copy link
Owner

@aalireza Thanks for opening this issue. I am looking into it.

@fxamacker fxamacker added the enhancement New feature or request label Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants