'Confusion over namespaces in doc comment tests
Very new to Rust, and I've run into an issue with trying to get doc comment tests working.
I'm hoping to have a module that isn't public, but has some tests in the doc comments.
src/lib.rs:
pub mod module;
fn foo() {
println!("{}", module::get_hello());
}
src/module.rs:
/// Gets a nice Hello message
///
/// ```
/// use test_namespace::module::get_hello;
/// let msg = get_hello();
/// assert_eq!(msg, "Hello, World!".to_string());
/// ```
pub fn get_hello() -> String {
"Hello, World!".to_string()
}
The only way I've been able to get this test working is if I have pub mod module;. I feel like there should be some way of running this test without the use test_namespace::module::get_hello; at all since it's a test in the same module. Hoping to get some clarification.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
