Creating Your First Rust Program

Creating a program that greets the user with “Hello, World” is a very popular way to kick the tires of a new programming language. Comparing “Hello, World” programs in different languages is a great way to get a feel for the syntax of a language without diving too deeply into specifics. The Hello World Collection provides “Hello, World” in 578 different programming languages.[8]

When you start a project with cargo new, Rust creates “Hello, World” for you. It also creates the necessary metadata for Cargo to be able to run your program.

Cargo Metadata

Open the Cargo.toml file created in your “Hello” project:

 [package]
 name = ​"hello"
 version = ​"0.1.0"
 authors = [​"Your ...

Get Hands-on Rust 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.