Creating Your First Rust Program
Let's create the first Rust program.
Creating a program that greets the user with “Hello, World” is a very popular way to test a new programming language.
When we start a project with cargo new
, Rust creates “Hello, world!” for us. It also creates the necessary meta-data for Cargo
to run our program.
Cargo Meta-data
We’ll open the Cargo.toml
file created in our hello
project:
This file describes our program and how to build it. It uses the TOML format (Tom’s Obvious, Minimal Language) and divides crate information into sections. The [package] section describes our crate; if we publish our crate, if we publish our crate, this information will be used to describe it to potential users. It can be extended to include a lot of information about our project.
Cargo has created everything we need to run “Hello, world”
, so we don’t have to edit the Cargo.toml
file if we don’t want to. The default entries are:
-
name
: : This is the name of your ...