Learn Rust in a Month of Lunches cover
welcome to this free extract from
an online version of the Manning book.
to read more
or

1 Some basics

 

This chapter covers

  • Introducing Rust
  • Using comments (putting human-readable hints in your code)
  • Some primitive types (simple numbers and other simple types)
  • Type inference (how Rust knows the type)
  • “Hello, World!” and printing
  • Declaring variables and code blocks
  • Shadowing (giving variables the same name)

This first chapter is as easy as Rust gets and has a bit of everything to get started. You’ll notice that even in Rust’s easiest data types, there’s a strong focus on the bits and bytes that make up a computer’s system. That means there’s quite a bit of choice, even in simple types like integers. You’ll also start to get a feel for how strict Rust is. If the compiler isn’t satisfied, your program won’t run! That’s a good thing—it does a lot of the thinking for you.

1.1 Introducing Rust

1.1.1 A pep talk

1.1.2 Rust is like a critical spouse

1.2 Comments

1.3 Primitive types: Integers, characters, and strings

1.4 Type inference

1.5 Floats

1.6 “Hello, World!” and printing

1.7 Declaring variables and code blocks

1.8 Display and Debug

1.9 Smallest and largest numbers

1.10 Mutability (changing)