A template for your next Rust project.

Overview

Opinionated Rust Template

A template for your next Rust project.

To start coding run:

cargo generate tomkarw/opinionated-rust-template

Only requires just to bootstrap all tools and configuration:

cargo install just

Includes:

  • quite strict clippy warnings; some lints are explicitly denied (those that have easy idiomatic alternatives).
  • opinionated rustfmt configuration: separate imports by std/external/crate, import granularity at module level and formatting string literals
  • just init for installing all necessary tools
  • pre-commit hooks for cargo {fmt,clippy,test}
  • just pre-commit command that additionally includes a spellcheck
  • GitHub CI pipeline taken from hyper project pipeline
  • skeleton for integration and e2e tests
  • skeleton for benchmarks with criterion
  • MIT and Apache 2.0 licenses

Description of included things

  • Conventional Commit - a specification for adding human and machine-readable meaning to commit messages
  • just - handy way to save and run project-specific commands
  • pre-commit - framework for managing and maintaining multi-language pre-commit hooks
  • cargo-nextest - next-generation test runner
  • cargo-spellcheck - check your spelling with hunspell and/or nlprule
  • cargo-llvm-cov - easily use LLVM source-based code coverage
  • criterion - helps you write fast code by detecting and measuring performance improvements or regressions
  • cargo-udeps - find unused dependencies in Cargo.toml
  • cargo-audit - audit Cargo.lock files for crates with security vulnerabilities reported to the RustSec Advisory Database
  • cargo-upgrades - shows which dependencies in Cargo.toml can be upgraded to a newer version
  • cargo-unused-features- allows you to find and prune enabled, but, potentially unused feature flags from your project

Other recommended tools

  • cargo-hack - test each feature independently and all combinations of feature powerset
  • cargo-modules - plugin for showing an overview of a crate's modules
  • cargo-geiger - tool that lists statistics related to the usage of unsafe Rust code in a Rust crate and all its dependencies

TODO

  • template project to provide --bin and --lib versions in cargo-generate
  • add all commands from just thorough-check to CI
  • add choice of FOSS licences (MIT/APACHE/both/neither)
  • add comments to all of just commands
  • add confirmation for each of steps performed in just thorough-check
  • extend pre-commit-rust with all things in just pre-commit
  • investigate cargo-sync-readme
  • investigate rust-semverver/cargo-public-api/cargo-semver-checks
  • meta: speed up build-template CI run

Similar projects

You can find similar templates via cargo-generate topic on GitHub

License

This project is licensed under either of:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Authors

Tomasz Karwowski LinkedIn

You might also like...
A blazing fast, type-safe template engine for Rust.

markup.rs A blazing fast, type-safe template engine for Rust. markup.rs is a template engine for Rust powered by procedural macros which parses the te

This is a template to build secret contracts in Rust to run in Secret Network

Secret Contracts Starter Pack This is a template to build secret contracts in Rust to run in Secret Network. To understand the framework better, pleas

A template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it.

CosmWasm Starter Pack This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it. To understan

🖨 Template for Rust applications & smart contracts @okp4.

Rust Template Template for Rust projects @okp4. Purpose & Philosophy This repository holds the template for building Rust projects with a consistent s

Minimal compile-time Rust template engine

boilerplate boilerplate is a minimal compile-time Rust text template engine. Quick Start Add boilerplate to your project's Cargo.toml: [dependencies]

Cloup is a template manager that provides the files you desire when you need them, written in Rust.
Cloup is a template manager that provides the files you desire when you need them, written in Rust.

cloup cloup is a template manager that delivers the files you desire when you need them, written in rust you no longer need to locate your previous pr

A template for command-line Rust programs

This is a template for command-line Rust programs. Clone and run the rename script with both a lowercase and UpperCase name. In the dev profile, depen

Rust-Rocket framework template Demo

rocketapp Rust-Rocket framework template Demo dependencies are defined in Cargo.toml Clone as: git clone https://github.com/srikantgdev/rocketapp [op

Rust Cannon Template 🦀 💣 💥

A build system and a minimal Rust program for building MIPS binaries that are executable in the context of [Optimism Cannon]

Comments
  • feature: apply even more feedback from introducing opinionated template to wasm-peers project

    feature: apply even more feedback from introducing opinionated template to wasm-peers project

    To test the usefulness (and whether it's not too strict) of this project, I tried to apply it retroactively (so not generating, but copying over all relevant bits) to my other project, wasm-peers in this PR.

    That in turn prompted me to apply improvements to this project.

    enhancement 
    opened by tomkarw 0
  • feat: utilise cargo-generate placeholders

    feat: utilise cargo-generate placeholders

    Utilize placeholders to introduce differences between library and binary projects generated.

    Binary template is mostly extended library template that additionally includes:

    • src/main.rs file
    • src/env.rs with mock Config struct sourced from env vars with envy crate and lazy loaded with once_cell crate
    • .env with placeholders for mock Config fields
    • test/e2e_tests.rs file
    • just watch script for running binary with hot-reload
    enhancement 
    opened by tomkarw 0
  • Investigate cargo-sync-readme

    Investigate cargo-sync-readme

    It would make sense to keep the README description of the generated project in sync with crate's root level documentation.

    There are tools to inject root level doc string from a crate into the README, one of such tool being https://github.com/phaazon/cargo-sync-readme.

    It would require adding the tool to just init script, updating template's README to specify the place where to inject the crate doc string and making it a part of just pre-commit script (and CI check).

    enhancement help wanted good first issue 
    opened by tomkarw 0
  • Extend pre-commit hooks with all things from `just pre-commit`

    Extend pre-commit hooks with all things from `just pre-commit`

    I forked https://github.com/doublify/pre-commit-rust (as https://github.com/tomkarw/pre-commit-rust) to extend it, so that it matches just pre-commit script. Alternatively, we could find a pre-commit recipe that allows running an arbitrary command and make it run just pre-commit.

    enhancement help wanted good first issue 
    opened by tomkarw 0
Owner
Tom Karwowski
CS graduate, ex-backend developer, Rust enthusiast, small-time open-source contributor and beginner systems engineer.
Tom Karwowski
A rust project template for general purpose.

Rust 项目的初始化模版 开发项目时,会有不少关于项目的ci, lint, typo等配置,通过该模板创建项目,帮助快速构建这些配置: github action 配置,用于在CI对代码进行完整的检查和构建 pre-commit 配置,用于在commit时进行代码规范检查,如: cargo fmt

fan-tastic-z 8 Sep 30, 2024
A template for starting a flipperzero-rs project for the Flipper Zero🐬

flipperzero-template ?? A template for kick-starting a Rust + FlipperZero project using flipperzero-rs ?? ❤️ ?? . Currently supports SDK 14.0 (flipper

Rust for Flipper Zero 5 Apr 4, 2023
Next-generation implementation of Ethereum protocol ("client") written in Rust, based on Erigon architecture.

?? Martinez ?? Next-generation implementation of Ethereum protocol ("client") written in Rust, based on Erigon architecture. Why run Martinez? Look at

Arthur·Thomas 23 Jul 3, 2022
Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain

Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain

Genolis 2 May 4, 2022
Validity is a next-generation, deduction-based language for formally verified, context-aware, autonomous & reactive smart contracts.

Validity Language Validity is a next-generation, deduction-based language for formally verified, context-aware, autonomous & reactive smart contracts.

Tempest Labs 4 Nov 11, 2022
CYFS:Next Generation Protocol Family to Build Web3

CYFS is the next-generation technology to build real Web3 by upgrading the basic protocol of Web (TCP/IP+DNS+HTTP). It has a subversive architectural design that everyone brings their own OOD (Owner Online Device) to form a truly decentralized network.

CYFS Core Dev Team 2k Jul 6, 2023
Bitcoin Push Notification Service (BPNS) allows you to receive notifications of Bitcoin transactions of your non-custodial wallets on a provider of your choice, all while respecting your privacy

Bitcoin Push Notification Service (BPNS) Description Bitcoin Push Notification Service (BPNS) allows you to receive notifications of Bitcoin transacti

BPNS 1 May 2, 2022
A library to help you sew up your Ethereum project with Rust and just like develop in a common backend

SewUp Secondstate EWasm Utility Program, a library helps you sew up your Ethereum project with Rust and just like development in a common backend. The

Second State 48 Dec 18, 2022
Temporary edit external crates that your project depends on

rhack You want to quickly put a sneaky macro kind of like dbg! into external crates to find out how some internal data structure works? If so rhack is

Ryo Nakao 119 Nov 3, 2022
Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana (WIP) ⛏👷🚧⚠️

Solana BPF Boilerplate Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana This boilerplate provides the following. Si

ono 6 Jan 30, 2022