I created a struct with some associated functions. One of those functions is a private function that is only used by tests, because I don't want to expose a private variable but I want to check its content in tests.
When I run
cargo test or
cargo build I get a dead code warning, but it works.
I have some questions though...
- Am I following a bad practice?
- Is this dead code compiled into my binary when I run
- Is there a way to tell cargo to ignore that function when I run
cargo build? I tried to add
#[test]before the function, but an error message tells me that it is not allowed with associated functions.