Cargo bench without extern crate

To use cargo bench, it seems the standard way is to have a benches directory in the same level as src, import the current library via extern crate ..., and then run the benchmarks. However, what if there're some internal APIs that I want to run benchmarks on, but don't want to expose them to outside. Is there a way to achieve that?


Try something based on;

mod file;

or maybe include!

You can use cfg(test) to expose internals only for testing/bench.


Thanks! do you have any example with this approach? does it mean these internals are only exposed for testing but cannot be used by other component (outside test) in the same library?

alternatively, you can try using

This looks really nice. Will definitely take a look. Thanks!