How to suppress “function is never used” warning for a function used by tests?

后端 未结 3 1057
北恋
北恋 2020-12-29 20:33

I\'m writing a program in Rust and I have some tests for it. I wrote a helper function for these tests, but whenever I build using cargo build it warns me that

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 21:01

    If something is only used in tests, it should be omitted altogether. This can be done with the #[cfg(test)] attribute.

提交回复
热议问题