Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pub struct MyStruct {
num: i32
}
impl MyStruct {
// setting to "pub", makes the warning disappear
fn new() -> MyStruct {
MyStruct { num : 2 }
}
pub fn add_num(&self, num: i32) -> i32 {
self.num + num
}
}
mod test {
#[test]
fn test_1() {
use crate::MyStruct;
let s = MyStruct::new();
assert_eq!(4, s.add_num(2));
}
}
----
$ rustc --version
rustc 1.32.0-nightly (4a45578bc 2018-12-07)
$ cargo check
Checking test2018 v0.1.0 (/home/user/tmp/test2018)
warning: method is never used: `new`
--> src/lib.rs:7:5
|
7 | fn new() -> MyStruct {
| ^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.