A template for binary executable Rust projects.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bauke e0a207f9b6
Update Cargo.toml and replace rust-bin-template in it automatically.
2 days ago
source Move to self-hosted Gitea. 1 week ago
.gitignore Initial commit. 3 months ago
Cargo.lock Initial commit. 3 months ago
Cargo.toml Update Cargo.toml and replace rust-bin-template in it automatically. 2 days ago
LICENSE Move to self-hosted Gitea. 1 week ago
README.md Update Cargo.toml and replace rust-bin-template in it automatically. 2 days ago
rustfmt.toml Initial commit. 3 months ago

README.md

Rust Binary Template

A template for binary executable Rust projects.

“Features”

AKA personal preferences.

  • source/ instead of src/ directory.
  • Main function with Result<(), Box<dyn Error>> return type for the ? operator.
  • Rustfmt configuration with:
    • 80 character max line length.
    • 2 space indentation.
  • Cargo lockfile not gitignored as per The Cargo Book.

Usage

The command below will:

  • Clone the project to new-project.
  • Change directory into it.
  • Remove the existing git history.
  • Initialize git to start anew.
  • Replace rust-bin-template in Cargo.toml with new-project.
git clone "https://git.holllo.cc/Bauke/rust-bin-template.git" new-project &&
cd $_ &&
rm -rf .git/ &&
git init &&
sed -i "s|rust-bin-template|$1|" "Cargo.toml"

Reusable Function

Add this to your .bashrc, .zshrc (or similar) configuration so you don’t have to copy-paste that whole command every time.

new-rust-bin () {
  git clone "https://git.holllo.cc/Bauke/rust-bin-template.git" "$1" &&
  cd "$1" &&
  rm -rf .git/ &&
  git init &&
  sed -i "s|rust-bin-template|$1|" "Cargo.toml"
}

Then use it as new-rust-bin new-project.

License

Open-sourced with the Unlicense.