hobofan / ambassador

Delegation of trait implementations via procedural macros
Apache License 2.0
245 stars 13 forks source link

Conditional Compilation #54

Closed Stebalien closed 3 weeks ago

Stebalien commented 2 months ago

I'd like to be able put a method on a delegatable trait behind a feature flag like so:

#[delegatable_trait]
trait MyTrait {
    fn foo(&self);
    #[cfg(feature = "enable-bar")]
    fn bar(&self);
}

#[derive(Delegate)]
#[delegate(MyTrait)]
struct MyStruct(SomeBaseStruct);

Unfortunately, it looks like ambassador is discarding cfg attributes.