jimlynchcodes-hello-world-rs-2 v0.0.2
Hello, World!
A barebones project that just prints the text "Hello, World"!
Backstory
Imagine you want to make the simplest Rust project possible- just the stuff needed to make a Rust project run.
The idea here is that if you can write a Rust project that compiles, runs, and does something then you can build off this and create all the things you could ever imagine! 🌈
The Exercise
Write the simplest Rust project possible that prints some form of, "Hello, World!" to the console.
Tests
Here I have one maybe pointless unit test just checking that the main function returns nothing.
I also have an integration test which verifies that the text "Hello, world!" is printed to the console and that the prompt appears on a new line.
I'm also adding some other interesting testing tools such as:
Running unit tests with a code coverage output
Running mutation tests to test the unit tests
Running fuzz tests to check for other unexpected behavior
Skills Practiced
Installing and using
cargoCreating a
mainfunctionCreating an integration test
Running a Rust project and tests
Dev Commands
Run cli tool locally:
cargo runFormatting / linting:
cargo fmt
cargo clippyRun unit & integration tests:
cargo testRun Units Tests Wih Code Coverage:
cargo tarpaulinRun Tests Automatically On Code Change (Aka "Watch Mode"):
bacon testRun Mutation Testing:
cargo mutantsDeploy to Cargo & NPM:
- Increment version in
Cargo.toml - Sign in with
cargo loginandnpm adduser
Then deploy (with -n flag for a different name):
rust-to-npm-cli deploy -b -n jimlynchcodes/01-hello-world-rsTo install via npm:
npm i -g @jimlynchcodes/hello-world-rsThen run:
hello-world-rs3 years ago