Copyright (c) 2020 Ronnie Song
This is a Rust based "unique" library crate that find the unique value from an iterator satisfying a predicate.
Check if 4 is unique in the nums. ```rust use unique::Unique;
let mut nums = vec![]; let num: fn(&&usize) -> bool = |&&n| n == 4;
nums.push(4); assert_eq!(Some(&4), nums.iter().unique(even)); //true ```
To run the example program, type the command below:
shell
$ cargo run --example example
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/examples/example`
None
None
Some(0)
Some(1)
None
None
Some(3)
None
Some("Ronnie")
Some("David")
Some("Ronnie")
None
Everything went well! It check and find the unique value from an iterator satisfying a predicate without issues, and successfully print results as expected.
To test the library crate, type the command below:
$ cargo test
```
Compiling unique v0.1.0 (/mnt/c/Users/ronsong/Desktop/Docs/Rust Programming/unique)
Finished dev [unoptimized + debuginfo] target(s) in 1.71s
Running target/debug/deps/test-e7e23989fe7c65fd
running 8 tests test testcases::empty ... ok test testcases::uniqueeven ... ok test testcases::uniqueodd ... ok test testcases::nonuniqueevenorodd ... ok test testcases::uniquenumber ... ok test testcases::nonuniquenumber ... ok test testcases::uniquename ... ok test testcases::nonunique_name ... ok
test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ```
All tests passed with no issues.
The tests are placed in tests/test.rs file that uses std assert_eq!() to test equality of the actual result and expected result of the unique() trait in that file.
Github Action CI is running to do the automated testing.
This program is licensed under the "MIT License". Please see the file LICENSE
in the source distribution of this software for license terms.