Skip to content

Conversation

@orthecreedence
Copy link
Contributor

This allows #[derive(Decode)] to be used in the following cases:

enum MyType<T> {
    // has no T
    Variant1(String),
    // uses T directly
    Variant2(T),
    // uses T indirectly
    Variant3(Vec<T>),
    // indirect T on struct variant
    VariantStruct4 {
	val: Vec<T>,
    }
}

Before, the <T> generic would be applied and expected to exist on ALL enum variants, causing compile errors when deriving.

Tests updated.

I feel it is my duty to disclose I did use AI assistance in this update. Derive macros and the intricacies of the supporting libraries are not my strong suit. I reviewed the result fully to make sure it's not doing anything "weird" but it's possible the implementation is overly verbose or incorrect in some obvious way. Tests are passing, but some additional scrutiny might be a good idea.

This allows `#[derive(Decode)]` to be used in the following cases:

```rust
enum MyType<T> {
    // has no T
    Variant1(String),
    // uses T directly
    Variant2(T),
    // uses T indirectly
    Variant3(Vec<T>),
    // indirect T on struct variant
    VariantStruct4 {
	val: Vec<T>,
    }
}
```

Before, the `<T>` generic would be applied and expected to exist on ALL
enum variants, causing compile errors when deriving.

Tests updated.
@XAMPPRocky
Copy link
Collaborator

Thank you for your PR!

@XAMPPRocky XAMPPRocky merged commit aa112b4 into librasn:main Jan 8, 2026
44 checks passed
@github-actions github-actions bot mentioned this pull request Jan 8, 2026
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

Successfully merging this pull request may close these issues.

2 participants