Amanieu / intrusive-rs

Intrusive collections for Rust
Apache License 2.0
423 stars 50 forks source link

Doc comments (and other attributes) within intrusive_adapter! macro #41

Closed cfoster0 closed 4 years ago

cfoster0 commented 5 years ago

It would be nice to be able to have attributes within intrusive_adapter! macro invocations.

I have #[deny(missing_docs)] on the module in which I use the macro, and I'd like to #[allow(missing_docs)] the stuff the macro produces, or even to have doc comments on the produced code. When I try the first, I run into a recursion limit reached while expanding the macro error.

Minimal code to reproduce:

struct Toy {
    link: RBTreeLink
}

intrusive_adapter!(
    #[allow(missing_docs)]
    pub ToyAdapter = Box<Toy> : Toy { link: RBTreeLink }
);

How easy would it be to modify the macro to preserve attributes?

Amanieu commented 5 years ago

I think this should be fairly simple to support since e.g. lazy_static supports this.