Rullst AcademyRullst Academy/Lesson
Rust: from idea to program · Lesson 02 / 08

Types are clear agreements

The robot must distinguish ten points, a yes/no answer and a name. Types help Rust avoid mixing these up accidentally.

Learning paths8 min

Let's discover together

  1. 1

    An integer represents a number without a fractional part. Here we use u32 for nonnegative points: 0, 1, 2... The type has a limit; it does not represent infinitely large numbers.

  2. 2

    bool has only two values: true and false. They are logical values, not quoted text. We can use them in decisions.

  3. 3

    "Robo" is text. In this example its type is &str, a reference to text. We will explore &str and String in the borrowing lesson.

  4. 4

    A colon declares the type: let ready: bool = true;. Rust often infers types, but writing them makes the agreement visible. Quoted "true" does not fit that bool.

✦
YOUR MISSION

Choose suitable types for three values and spot a mismatch.

Now it's your turn

Discovery workshop

Label the values

Complete the declarations using u32, bool or &str. Each type has a different job.
Your snippet in progress
let points: {1} = 10;
let ready: {2} = true;
let name: {3} = "Robo";
Build your answers and check when you are ready.
A moment to understand

Which assignment respects the bool type?

I need a hint

Quotes turn true into text; without quotes, true is a bool value.

Loading your journey…

Take it with you

For an attempt counter, an on/off switch and a title, choose one of these types and explain why.

Show me the Rust behind it

This part is optional. You don't need to memorize the code to continue.

fn main() {
    let points: u32 = 10;
    let ready: bool = true;
    let name: &str = "Robo";
    println!("{name}: {points}, {ready}");
}
At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.