Variables, Constants, and Data Types
Last updated
What is Variables, Constants, and Data Types?
In Rust, variables are declared using the let keyword. All variables are immutable by default, which means once a value is bound to a variable, it cannot be changed. If you want to make a variable mutable, the mut keyword is used. So, if you wanted to declare a mutable variable x and assign it the value 5, you would write let mut x = 5;. Variables can also be patterned. By default in Rust, variables are block-scoped. Rust also supports several types of variable attributes.
Free resources to learn Variables, Constants, and Data Types
- Official docsVariables and Mutability
- Official docsData Types
- Official docsConstants
More in stage 2: Language Basics
Variables, Constants, and Data Types: common questions
Can I learn Variables, Constants, and Data Types in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Variables, Constants, and Data Types in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Variables, Constants, and Data Types tutorial for beginners?
It is lesson 5 of 122 in the free Rust roadmap, in stage 2, Language Basics. If you are new to Rust, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.