utils.rs // I need the function to be inside a module // in order to be able to mock it in tests mod utils { pub fn foo() {} #[cfg(test)] mod tests { use super::*; } } lib.rs fn bar() { foo() }