From d8f86e8e1b365d352a9388cebb8d4f9f4ad85084 Mon Sep 17 00:00:00 2001 From: ChrisLinn Date: Wed, 17 Jul 2019 23:01:59 +0800 Subject: [PATCH 01/31] init single-number.rs --- kamyu104/src/single-number.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 kamyu104/src/single-number.rs diff --git a/kamyu104/src/single-number.rs b/kamyu104/src/single-number.rs new file mode 100644 index 0000000..6c9d926 --- /dev/null +++ b/kamyu104/src/single-number.rs @@ -0,0 +1,17 @@ +#[allow(dead_code)] +pub fn add(a: i32, b: i32) -> i32 { + // only print when a test fails + println!("{}", a + b); + return a + b; +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_add() { + assert_eq!(add(1, 2), 3); + assert_ne!(add(1, 2), 4); + } +} \ No newline at end of file From 9b76509e13391c157cc484b5b1960adf6b820846 Mon Sep 17 00:00:00 2001 From: ChrisLinn Date: Wed, 17 Jul 2019 23:03:39 +0800 Subject: [PATCH 02/31] fix path --- README.md | 2 +- kamyu104/src/main.rs | 3 ++- kamyu104/src/{single-number.rs => single_number.rs} | 0 3 files changed, 3 insertions(+), 2 deletions(-) rename kamyu104/src/{single-number.rs => single_number.rs} (100%) diff --git a/README.md b/README.md index 80fd79e..01eb94e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ cargo test #### Bit Manipulation | # | Title | Solution | Time | Space | Difficulty | Tag | Note| |-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----| -0136 | [Single Number](https://leetcode.com/problems/single-number/) | [C++](https://github.com/kamyu104/LeetCode-Solutions/blob/master/C++/single-number.cpp)
[Python](https://github.com/kamyu104/LeetCode-Solutions/blob/master/Python/single-number.py)
[Rust](./kamyu104/src/single-number.rs) | _O(n)_ | _O(1)_ | Easy ||| +0136 | [Single Number](https://leetcode.com/problems/single-number/) | [C++](https://github.com/kamyu104/LeetCode-Solutions/blob/master/C++/single-number.cpp)
[Python](https://github.com/kamyu104/LeetCode-Solutions/blob/master/Python/single-number.py)
[Rust](./kamyu104/src/single_number.rs) | _O(n)_ | _O(1)_ | Easy ||| +