|
|
|
CroftSoft
/
Library
/
Tutorials
Rust Project Setup
2023 Mar 10 Fri
David Wallace Croft
Links
In recommended reading order
Project Setup
-
Install
Visual Studio Code (VS Code)
-
You will want to install this before you install git
-
Install
git
-
When it prompts you to select your editor, choose VS Code
-
Install
Rust
-
If you previously installed Rust, you can update it:
rustup update
-
Install the following VS Code extensions
-
Use cargo to make the project directory
cargo new project-name
-
Test your setup
cd project-name/
cargo run
-
Open VS Code
code .
-
Add properties to the package section of your Cargo
manifest file Cargo.toml
[package]
authors = ["First Middle Last <email.username@domain-name.com>"]
# Use the categories from https://crates.io/categories
categories = ["category-name"]
description = "project description"
edition = "2021"
homepage = "https://www.domain-name.com/"
# https://doc.rust-lang.org/cargo/reference/manifest.html#the-keywords-field
keywords = ["keyword"]
# Remark this line out if your project is not open source
license = "MIT"
name = "project-name"
# Change this value to true when you publish to crates.io
publish = false
readme = "README.md"
# Remark this line out if your project is not in a code repository
repository = "https://github.com/github-username/project-name"
version = "0.1.0"
-
Make a README.md file in your project root directory
# Project Name
- Project description
## Usage
- cd project-name/
- cargo run
## History
- Initial release: YYYY-MM-DD
-
Make a
rustfmt.toml
in your project root directory
# https://rust-lang.github.io/rustfmt/
array_width = 1
# blank_lines_lower_bound = 1
chain_width = 80
fn_args_layout = "Vertical"
# group_imports = "StdExternalCrate"
hard_tabs = false
# imports_layout = "HorizontalVertical"
match_block_trailing_comma = true
# https://www.w3.org/WAI/tutorials/page-structure/styling/#line-length
max_width = 80
merge_derives = true
newline_style = "Unix"
remove_nested_parens = true
reorder_imports = true
reorder_modules = true
single_line_if_else_max_width = 0
struct_lit_width = 0
struct_variant_width = 0
tab_spaces = 2
use_try_shorthand = true
# version = "Two"
# wrap_comments = true
-
If your project is open source, make a LICENSE.txt file
MIT License
Copyright (c) [year] [copyright-holder-name]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-
Commit your code changes
git add .
git commit -m "Rust project setup"
-
Push to your remote code repository
git push
© 2022-2023
CroftSoft Inc
|
|
|
|
|
|