Hello Cargo - Your First Rust Project | Rust by Examples (Lesson 1)
Video: Hello Cargo - Your First Rust Project | Rust by Examples (Lesson 1) by Taught by Celeste AI - AI Coding Coach
Watch full page →Hello Cargo - Your First Rust Project
Getting started with Rust is simple and efficient using Cargo, Rust’s built-in package manager and build tool. In this lesson, you will learn how to create a new Rust project, understand its structure, and run your first program using Cargo commands.
Code
// src/main.rs
fn main() {
// Print a greeting message to the console
println!("Hello, Cargo! Welcome to your first Rust project.");
// Add a second message
println!("This is powered by Rust and managed by Cargo.");
}
Key Points
- Use
cargo new project_nameto create a new Rust project with the standard structure. - The
Cargo.tomlfile defines your project metadata and dependencies. - Your Rust source code lives in
src/main.rs, which contains the program’s entry point. cargo checkquickly verifies your code without producing binaries.cargo buildcompiles your project, andcargo runcompiles and executes it in one step.- The
println!macro outputs text to the console; the exclamation mark indicates it’s a macro, not a function.