There is one warning in this test:
warning: function show_char
is never used
pub fn add(left: usize, right: usize) -> usize {
left + right
}
fn show_char(a_char: char) {
if a_char == 'A' {
println!("/////{}/////", a_char);
} else {
panic!("======={}======", a_char);
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn will_ok() {
show_char('A');
}
// #[ignore]
#[test]
fn will_err() {
show_char('a');
}
}
output:
warning: function `show_char` is never used
--> src\lib.rs:5:4
|
5 | fn show_char(a_char: char) {
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: `lib-sample01` (lib) generated 1 warning
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src\lib.rs (target\debug\deps\lib_sample01-db19219f39bd4e4a.exe)
running 2 tests
test tests::will_err ... FAILED
test tests::will_ok ... ok
failures:
---- tests::will_err stdout ----
thread 'tests::will_err' panicked at src\lib.rs:9:9:
=======a======
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
tests::will_err
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
error: test failed, to rerun pass `--lib`
but it's no warning when i use pub fn show_char
instead of fn show_char
.
what is the reason for this?
cargo --version : cargo 1.75.0 (1d8b05cdd 2023-11-20)