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

For a generic struct Wrapper<T>, set different root elements for different possible values of T #53

Open
vastvik123 opened this issue Jun 19, 2024 · 1 comment

Comments

@vastvik123
Copy link

vastvik123 commented Jun 19, 2024

#[derive(XmlSerialize)]
struct Wrapper<T:XmlSerialize> {
  #[xmlserde(name = b"header", ty = "attr")]
  header: String,
  #[xmlserde(ty = "untag")]
  body: T,
}

The above struct Wrapper is a generic struct, T can have different types. I want to set different root element for every possible T.
How to achieve this?

@vastvik123 vastvik123 changed the title Set different root for generic types based on the type parameter For a generic struct Wrapper<T>, set different root elements for different possible values of T Jun 19, 2024
@ImJeremyHe
Copy link
Owner

@vastvik123 Sorry for the late reply. For now we don't support the generic types well. I think the only way to accomplish this is to define different types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants