OpenViSTAI · Agents · Blockchain · Crypto
Menu

OPENVIST LEARN · FREE LESSONS

Cargo and your project folder

Create a Cargo package and distinguish source from build output.

Lesson 2 of 30 · About 20 minutes · Beginner · English

By the end of this lesson

Create a Cargo package and distinguish source from build output.

Before you start

  • Rust 1.90.0 or later, a terminal and a plain-text editor. Examples were tested with Rust 1.90.0, Edition 2024 on Linux.
  • Complete lesson 1, or be comfortable explaining and running its examples.

Three words to know

Package
A project described by Cargo.toml.
Manifest
The Cargo.toml configuration file.
Build output
Generated files in target; not your source.

1. Understand the idea

Cargo coordinates builds and tests. cargo new creates a named folder containing Cargo.toml and src/main.rs. Run Cargo inside that folder or point it to the manifest. Cargo.toml is configuration, not Rust. target is generated output; changing a file there is not how you edit the program. The --vcs none option avoids creating an extra Git repository for this exercise.

2. Save, run and observe

Save this complete program as src/main.rs in a fresh practice folder. It replaces that lesson file only; keep earlier examples separately. Compile it with rustc, then run the executable. Rust source goes in the editor; rustc and cargo commands go in the terminal.

Create a practice packageTERMINAL · Bash or Windows PowerShell
cargo new openvist-greeting --bin --vcs none
cd openvist-greeting
cargo run
What you should see · example output
Cargo creates the package and runs its starter greeting; progress wording can vary.
Replace src/main.rsRUST · save as src/main.rs
fn main() { println!("Cargo runs my saved source"); }
What you should see · example output
Cargo runs my saved source

3. Explain the result

After replacing src/main.rs, run cargo run again from the package root. Cargo recompiles when needed. The line from println! goes to stdout; Cargo build/run messages normally go to stderr. Your editor should show the same path printed by your terminal. Do not run cargo new again in an existing project.

YOUR TURN

A small check before you continue

Where should you edit the greeting: Cargo.toml, src/main.rs or target?

Show a suggested answer

Edit src/main.rs. Cargo.toml describes the package; target contains generated build artifacts.

Sources and scope

Documentation and examples reviewed 2026-10-18. Provider screens, package versions and output wording can differ. Examples show expected outcomes; they are not a claim that OpenViST connected to your server or verified your setup.