Loading...
Loading...
9rustvariables

Understanding Variables in Rust

This guide introduces variables in Rust, explaining the let keyword and how to use it to declare mutable and immutable variables.


Variable Declaration in Rust

Variables in Rust are declared using the let keyword. To make a variable mutable, add mut:

// Declaring variables in Rust
let name = "Rust";    // Immutable
let mut age = 3;      // Mutable
age = 4;              // Allowed since it's mutable
0 Interaction
1.9K Views
Views
35 Likes
×
×
×
🍪 CookieConsent@Ptutorials:~

Welcome to Ptutorials

$ Allow cookies on this site ? (y/n)

top-home