How can I conditionally execute a module-level doctest based on a feature flag?
问题 I am writing documentation for a module that has some options controlled by a Cargo feature flag. I'd like to always show this documentation so that consumers of the crate know that it's available, but I need to only run the example when the feature is enabled. lib.rs //! This crate has common utility functions //! //! ``` //! assert_eq!(2, featureful::add_one(1)); //! ``` //! //! You may also want to use the feature flag `solve_halting_problem`: //! //! ``` //! assert!(featureful::is_p_equal