lesurp / OptionalStruct

Macro copying a struct with Option fields. Useful for config initialization
Apache License 2.0
36 stars 12 forks source link

Support for generic types #6

Closed azriel91 closed 6 years ago

azriel91 commented 6 years ago

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?

lesurp commented 6 years ago

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 :)

lesurp commented 6 years ago

@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).

azriel91 commented 6 years ago

hey, that was fast! The new release works like a charm, thank you very much :bowing_man:!