From c172ecc4e89fcbe77e0d69ccc6b9ba1738b25f17 Mon Sep 17 00:00:00 2001 From: llgoer Date: Tue, 26 Nov 2019 17:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AA=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 11 +++++++++++ Cargo.toml | 9 +++++++++ src/lib.rs | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0daf272 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +/target +**/*.rs.bk + + +#Added by cargo +# +#already existing elements are commented out + +#/target +#**/*.rs.bk +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c20a2e9 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "add" +version = "0.1.0" +authors = ["llgoer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..5c83c9b --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,22 @@ +// Copyright 2019 GoKeep Author. All rights reserved. +// license that can be found in the LICENSE file. + +pub fn add(a: i32, b: i32) -> i32 { + a + b +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_add() { + assert_eq!(add(1, 2), 3); + } + + + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +}