© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
C. MilanesiBeginning Rusthttps://doi.org/10.1007/978-1-4842-7208-4_1

1. Getting Started

Carlo Milanesi1  
(1)
Bergamo, Italy
 
In this chapter, you will learn:
  • How to write and run your first program in the Rust language

  • How to print text and numbers on the terminal

  • How to write comments in your code

How to Start

The smallest valid Rust program is this:
fn main(){}

Of course, it does nothing. It just defines an empty function named “main.” By “function” we mean a set of instructions that does something, and that has been given a name.

fn is shorthand for “function,” while main is the name of this function. The round parentheses contain the function’s possible arguments; ...

Get Beginning Rust: Get Started with Rust 2021 Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.