In a library crate I want to make backtraces available on demand and use the Rust nightly backtrace feature. In order to do that, Rust requires setting #![feature(backtrace)]
in my crate root.
Is there a way to express I want Rust nightly feature "backtrace" only when my create level feature "backtraces" is set?
Non compiling pseudo code to help illustrating what I have in mind:
#[cfg(feature = "backtraces")]
#![feature(backtrace)]
You can use cfg_attr
:
#![cfg_attr(feature = "backtraces", feature(backtrace))]
If the first argument is true then the subsequent attribute(s) will be applied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With