I'm looking for a way to provide special functionality based on a dependency's feature selection.
There is a library crate-a with features feature-a and feature-b. I would like to crate a new library crate-b which depends on crate-a.
Binary crate-c depends on both crate-a and crate-b and specifies features for crate-a.
I would like to provide a different implementation of crate-b's function greet based on the feature set selected for crate-a.
I've tried this approach which doesn't work:
// at crate-b/src/lib.rs
#[cfg(not(feature = "crate-a/feature-a"))]
pub fn greet() {
println!("General impl");
}
#[cfg(feature = "crate-a/feature-a")]
pub fn greet() {
println!("Feature-A impl");
}
Is there any way to check crate-a's features from crate-b?
I control both crate-a and crate-b. Even an approach where something should be changed in crate-a works for me.