Rust Functions Tutorial | Parameters & Return Values for Beginners (2026)

3views
00
4:58
T
Taught by Celeste AI - AI Coding Coach
View on YouTube
Description
Learn how to create and use functions in Rust! This beginner tutorial covers basic functions, parameters, and return values with clear code explanations. šŸ”„ In This Tutorial: ━━━━━━━━━━━━━━━━━━━━━━━ 0:00 - Intro 0:06 - Basic Functions (fn keyword) 1:38 - Function Parameters (&str) 3:08 - Return Values (arrow type) 4:51 - Outro šŸ“š What You'll Learn: ━━━━━━━━━━━━━━━━━━━━━━━ āœ… Create functions with the fn keyword āœ… Call functions from main() āœ… Pass parameters to functions āœ… Use &str for string parameters āœ… Return values with arrow syntax āœ… Implicit return (no semicolon) šŸ’» Code Examples: ━━━━━━━━━━━━━━━━━━━━━━━ // Basic function fn greet() { println!("Hello from a function!"); } // Function with parameter fn greet(name: &str) { println!("Hello, {}!", name); } // Function with return value fn add(a: i32, b: i32) returns i32 { a + b // No semicolon = return! } ⚔ Key Concepts: ━━━━━━━━━━━━━━━━━━━━━━━ → Functions are defined with 'fn' → Parameters have type annotations: name: &str → Return type uses arrow syntax → Last expression without semicolon is returned → main() is always the entry point šŸ› ļø Tools Used: ━━━━━━━━━━━━━━━━━━━━━━━ → rustc (Rust compiler) → nvim (code editor) šŸ‘ Like & Subscribe for more Rust tutorials! #rust #rustlang #programming #functions #tutorial #beginners #coding #learnrust
Back to tutorials

Duration

4:58

Published

December 21, 2025

Added to Codegiz

March 15, 2026

Open in YouTube