|
| 1 | +# Rust Template |
| 2 | + |
| 3 | +## Environment settings |
| 4 | + |
| 5 | +### Install Rust |
| 6 | + |
| 7 | +```bash |
| 8 | +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| 9 | +``` |
| 10 | + |
| 11 | +### Install VSCode Extensions |
| 12 | + |
| 13 | +- crates: Rust package management |
| 14 | +- Even Better TOML: TOML file support |
| 15 | +- Better Comments: Optimized comment display |
| 16 | +- Error Lens: Improved error prompts |
| 17 | +- GitLens: Enhanced Git features |
| 18 | +- Github Copilot: Code suggestions |
| 19 | +- indent-rainbow: Indentation display optimization |
| 20 | +- Prettier - Code formatter: Code formatting tool |
| 21 | +- REST client: REST API debugging tool |
| 22 | +- rust-analyzer:Rust language support |
| 23 | +- Rust Test lens:Rust test support |
| 24 | +- Rust Test Explorer:Rust test overview |
| 25 | +- TODO Highlight:TODO highlighting |
| 26 | +- vscode-icons:Icon optimization |
| 27 | +- YAML:YAML file support |
| 28 | + |
| 29 | +### Install cargo generate |
| 30 | + |
| 31 | +cargo generate is a tool for generating project templates. It can use an existing GitHub repo as a template to generate a new project. |
| 32 | + |
| 33 | +```bash |
| 34 | +cargo install cargo-generate |
| 35 | +``` |
| 36 | +The new project will use the `upupnoah/rust-template` template to generate basic code:: |
| 37 | + |
| 38 | +```bash |
| 39 | +cargo generate upupnoah/rust-template |
| 40 | +``` |
| 41 | + |
| 42 | +### Install pre-commit |
| 43 | + |
| 44 | +pre-commit is a code checking tool that can perform code checks before committing code. |
| 45 | + |
| 46 | +```bash |
| 47 | +pipx install pre-commit |
| 48 | +``` |
| 49 | + |
| 50 | +After successful installation, run `pre-commit install`. |
| 51 | + |
| 52 | +### Install cargo-deny |
| 53 | + |
| 54 | +Cargo deny is a Cargo plugin that can be used to check the security of dependencies. |
| 55 | + |
| 56 | +```bash |
| 57 | +cargo install --locked cargo-deny |
| 58 | +``` |
| 59 | + |
| 60 | +### Install typos |
| 61 | + |
| 62 | +Typos is a spell checking tool. |
| 63 | + |
| 64 | +```bash |
| 65 | +cargo install typos-cli |
| 66 | +``` |
| 67 | + |
| 68 | +### Install git-cliff |
| 69 | + |
| 70 | +git cliff is a tool for generating changelogs. |
| 71 | + |
| 72 | +```bash |
| 73 | +cargo install git-cliff |
| 74 | +``` |
| 75 | + |
| 76 | +### Install cargo nextest |
| 77 | + |
| 78 | +cargo nextest is an enhanced testing tool for Rust. |
| 79 | + |
| 80 | +```bash |
| 81 | +cargo install cargo-nextest --locked |
| 82 | +``` |
| 83 | + |
| 84 | +## Template Usage |
| 85 | + |
| 86 | +1. cargo generate rust-noah/rust-template |
| 87 | + |
| 88 | +2. Enter the directory, modify the cliff.toml file, change the URL after replace= to your own repository address (you need to create a repository first) |
| 89 | + 1. Create an empty repository on GitHub (excluding README, .gitignore, and LICENSE). |
| 90 | + 2. cd new-project-dir (Name of the new project) |
| 91 | + 3. Execute the command in the empty project created in step 1 (git remote add ...) |
| 92 | + |
| 93 | +3. pre-commit install |
| 94 | + |
| 95 | +4. Change the package.name in the Cargo.toml file to the name of the new project. |
| 96 | + |
| 97 | +Note: |
| 98 | +- If git commit encounters problems, please delete `deny.toml` and then execute `cargo deny init` |
| 99 | + - Add the code below to licenses. |
| 100 | + ```toml |
| 101 | + unlicensed = "allow" |
| 102 | + allow = [ |
| 103 | + "MIT", |
| 104 | + "Apache-2.0", |
| 105 | + "Unicode-DFS-2016", |
| 106 | + "MPL-2.0", |
| 107 | + "BSD-2-Clause", |
| 108 | + "BSD-3-Clause", |
| 109 | + "ISC", |
| 110 | + "CC0-1.0", |
| 111 | + ] |
| 112 | + ``` |
0 commit comments