Small app used for learning Rust
$ make release
$ ./target/release/contacts-cli
Check out the makefile for all the available targets
$ make help
Contacts CLI
Usage:
help Prints this help message
build Compile the current package
update Update the dependencies of the current package
run Run a binary of the local package
check Analyze the current package and report errors, but don't build object files
release Release the current package
clean Clean the current package
fmt Format all Rust files of the current crate
test Run the tests
phone_no
is validated againstr"49[0-9]{9,10}"
email
is validated againstr"^([a-z0-9_+]([a-z0-9_+.]*[a-z0-9_+])?)@([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6})"
pub struct Contact {
pub name: String,
pub phone_no: u64,
pub email: String,
}
In memory tree map, using the name
as key.
contacts: BTreeMap<String, Contact>,
- cargo init => 2cfa2b1
- one makefile to rule them all => f69fac3
- play with btreemap => 92e3036
- validation using regex => 35c2965
- separate business logic => 90e923c
- no panics in business logic => d78bbcb
- traits and implementations => 5fc86ff
- tests => e233838
- refined api, separate validation => 06b368a
- lazy loading for regexes, simplify validation => 6ac683a
- separate module with private fields and methods => 1bdf4ce
- repl => 574d189
- export to json => 06f2341
- import from json => 2489426
- refactor error logic => fcdb8ab
- defensive programming style => 16025e0
- list and count => c56818a
- search