Topic Overview and Goal Setting

Welcome back to your Rust journey! Let's immerse ourselves in the exploration of Rust Variables — our key constructs. Similar to a cornerstone, variables provide structure to our code, enriching it with data and information.

A variable in coding is like a bookmark — a dedicated place in memory where a value is stored. This session aims to familiarize you with the concept of Rust variables, their declaration, naming rules, value assignments, and the concept of immutable variables.

What are Rust Variables?

Think of Rust variables as sticky notes imprinted with data. The short example below explains how to create a variable in Rust:

Let's break down each line of the code.

  1. let number_of_stars: i32;

    This line is similar to creating a new sticky note and labeling it number_of_stars. The let keyword is used to declare a variable named number_of_stars with the data type i32 (a signed 32-bit integer). For now, don't worry about the i32 part; we'll cover data types in a subsequent lesson.

  2. number_of_stars = 88;

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal