Skip to content

Instantly share code, notes, and snippets.

@Ch00k
Last active January 6, 2021 10:48
Show Gist options
  • Save Ch00k/efb27afca8ca3456a163f005f2afa09e to your computer and use it in GitHub Desktop.
Save Ch00k/efb27afca8ca3456a163f005f2afa09e to your computer and use it in GitHub Desktop.

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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment