Skip to content

Instantly share code, notes, and snippets.

@apiraino
Last active December 13, 2018 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apiraino/744729b62bafcc551b7b45b9b424a130 to your computer and use it in GitHub Desktop.
Save apiraino/744729b62bafcc551b7b45b9b424a130 to your computer and use it in GitHub Desktop.
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