© Carlo Milanesi 2018
Carlo MilanesiBeginning Rusthttps://doi.org/10.1007/978-1-4842-3468-6_1

1. Printing on the Terminal

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 output texts and numbers on the terminal

  • How to write a small script that makes more readable the output of the compiler

  • How to write comments in your code

How to Start

The smallest valid Rust program is:

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.

The "fn" word is shorthand for “function”. The "main" word is the name of the function . The round parentheses contain ...

Get Beginning Rust: From Novice to Professional 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.