How to pass feature value to nested rust lib crate

I got a rust project has the folder structure below:

adas-demo
     |-- Cargo.toml
     | 
     |-- opencv-utils
               |-- Cargo.toml

Both parent crate and nested lib crate got the enable-debug feature which I use to print out some debug info like below:

#[cfg(feature = "enable-debug")]
{
   // ....
}

So, I run the project like this:

    LOG_LEVEL=DEBUG \
    SHOW_RENDER_WINDOW=true \
    cargo watch --clear --exec 'run --features "enable-debug"'

But "enable-debug" feature doesn't apply to opencv-utils, any easy way to solve this?

In Cargo.toml for adas-demo, change line 16 to enable-debug = ["opencv-utils/enable-debug"]. I think that usage should be self-explanatory, but say so if not!

1 Like

@jhpratt Thanks for that, it works perfectly :blush:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.