diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 0000000..9a9fb4d --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1,2 @@ +# Cargo build output +/target diff --git a/rust/.tool-versions b/rust/.tool-versions new file mode 100644 index 0000000..367295f --- /dev/null +++ b/rust/.tool-versions @@ -0,0 +1 @@ +rust 1 diff --git a/rust/README.md b/rust/README.md index d248b87..d062192 100644 --- a/rust/README.md +++ b/rust/README.md @@ -1,14 +1,29 @@ # Rust -Skeleton project for Rust.\ -It is assumed that Rust is installed on your machine. If not, please follow the [installation guide](https://www.rust-lang.org/tools/install). +Skeleton project for Rust. + +## Prerequisites + +The toolchain this project needs is declared in [`.tool-versions`](./.tool-versions): + +``` +rust 1 +``` + +Install those however you prefer, as long as they end up on your `PATH`. The quickest route is +[mise](https://mise.jdx.dev/), which reads the file for you: + +```sh +mise install +``` ## Usage +- `./script/setup` to fetch dependencies - `./script/test` to run the tests -- `./script/start` to run the code +- `./script/start` to run the app ## Structure - Code located in [`main.rs`](./src/main.rs) - Tests located in [`lib.rs`](./src/lib.rs) -However, you're free to organise your code as you like. +However, you're free to organise your code as you like. diff --git a/rust/script/setup b/rust/script/setup new file mode 100755 index 0000000..e89fa92 --- /dev/null +++ b/rust/script/setup @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +cargo fetch diff --git a/rust/script/start b/rust/script/start index e474a3f..e436496 100755 --- a/rust/script/start +++ b/rust/script/start @@ -1,5 +1,7 @@ #!/usr/bin/env bash -set -e +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." cargo run diff --git a/rust/script/test b/rust/script/test index e48306a..e2b669f 100755 --- a/rust/script/test +++ b/rust/script/test @@ -1,5 +1,7 @@ #!/usr/bin/env bash -set -e +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." cargo test