Last active
December 13, 2018 17:59
-
-
Save apiraino/744729b62bafcc551b7b45b9b424a130 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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