lesurp/OptionalStruct

Support for generic types

Closed this issue · 3 comments

Hiya! Thanks for making this crate, it's just the crate I was looking for.
There's a use case where the derive isn't happy though:

#[derive(OptionalStruct)]
pub struct MyStruct<T> {
    data: T,
}

It doesn't like the <T> and fails with:

error[E0412]: cannot find type `T` in this scope

Simple repository to reproduce: optional_struct_generics

Do you think it would be easy to add support for this?

Hi, glad to see this is useful to somebody!
It's been a while since I last worked on this, but I'll try to see what I can do :)

@azriel91 I realized I had a stable_channel branch, as custom attributes cannot be used on stable rust.

I decided to ditch the whole custom attributes for now, and to merge that branch to master (where the fix for this issue has been merged has shown above).

This means you will just need to update your version in your Cargo.toml to 2.0 (assuming you were using the stable_channel version).

hey, that was fast! The new release works like a charm, thank you very much 🙇‍♂️!