Oxidation 1 - Cargo, Rustdoc

What is rustup, rustc & rustdoc ?

rustup- Used to update the latest Rust version. rustc filename.rs - Used to compile rust source code. rustdoc - Rust documentation is generated from this command. This can generate documentation from markdown files. Also, it show the Rustbook opens in browser when called as rustup docs

Project initialization After installing Rust, we should initialize a project using Cargo cargo init project_path - This will create a project folder of below file structure.

Project folder - File Structure

To work in Rust, you should have a project folder. The folder structure is like below.

Project_name
  ├── src
  │     └──main.rs
  ├── target
  ├── Cargo.lock
  └── Cargo.toml
  • src - Source folder: Source code lies under this folder The rust files are of ‘.rs’ extension. We can have as many rust files under the folder

  • target - Target folder: The final executables lies in this folder. The final executable will be created on using cargo build --release and will be ready for production.

  • Cargo.toml: This is a manifest file that holds package & dependent package details.

Below is the sample Cargo.toml file created in my project.

[package]
name = "Euler-Rust"
version = "0.1.0"
authors = ["dheepakg <email_id@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]


I’m using VS Code IDE. So, after doing the Cargo init, I open the project in VS Code. That’s it. We would have src/main.rs will be ready for execution. We can learn further by modifying the file.

Page source

Page last updated on: 2024-11-06 09:30:05 +0530 +0530
Git commit: a98b4d9


See also