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

๐Ÿ“– Read the articleOpen in YouTube