Amanieu / intrusive-rs

Intrusive collections for Rust
Apache License 2.0
400 stars 47 forks source link

Add const constructor to intrusive_adapter #11

Closed penberg closed 7 years ago

penberg commented 7 years ago

This adds a const constructor to intrusive_adapter macro. It's useful when initializing a static variable, for example.

penberg commented 7 years ago

Why does rustdoc --test fail with nightly?

Amanieu commented 7 years ago

The rustdoc tests fail because they don't enable the const_fn feature. This can be solved by using the #[allow_internal_unstable] attribute on the macro.

However there is another problem with your code: the #[cfg] is evaluated in the crate that uses the macro rather than the one that defines it. This obviously isn't what we want. Solving this requires moving the #[cfg] outside the macro, which means that the entire macro needs to be duplicated.

I implemented this in 92369a491d643952a94e3a0568b68df3a97736a1, see the comment at the top. I also published v0.6.4 with this change.

penberg commented 7 years ago

Awesome, thanks @Amanieu!