CroftSoft / Library / Tutorials

Rust Project Setup

2022-11-20

David Wallace Croft


Contents

Links

In recommended reading order

Project Setup

  1. Install git
  2. Install Rust
    • If you previously installed Rust, you can update it:
    rustup update
  3. Install Visual Studio Code (VS Code)
  4. Install the following VS Code extensions
  5. Use cargo to make the project directory cargo new project-name
  6. Test your setup cd project-name/ cargo run
  7. Open VS Code code .
  8. Add properties to the package section of your Cargo manifest file Cargo.toml [package] name = "project-name" version = "0.1.0" authors = ["David Wallace Croft <david@croftsoft.com>"] # Use the categories from https://crates.io/categories categories = ["category-name"] description = "project description" edition = "2021" homepage = "https://www.croftsoft.com/" keywords = ["keyword"] # Remark this line out if your project is not open source license = "MIT" # Remark this line out 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/david-wallace-croft/project-name"
  9. 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
  10. 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
  11. 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.
  12. Commit your code changes git add . git commit -m "Rust project setup"
  13. Push to your remote code repository git push


© 2022 CroftSoft Inc

 
 
 
CroftSoft
 
 
About
Library
- Books
- Code
- Courses
- Links
- Media
- Software
- Tutorials
People
Portfolio
Update
 
 
Google
CroftSoft Web