Creating Your First Rust Program
Hands-on Rust — by Herbert Wolverson (16 / 120)
👈 Managing Projects with Cargo | TOC | Using Cargo to Build, Check, or Run Your Proje ct 👉
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:
InstallingRust/HelloWorld/Cargo.toml
[package]
name = "hello"
version = "0.1.0"
authors = ["Your Name"]
edition = "2018"
# See more keys and their definitions at
# https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
This file describes your program and how to build it. It uses the TOML format (Tom’s Obvious, Minimal Language), and divides information about your crate into sections.[9] The [package] section describes your crate — if you publish your crate, this information will be used to describe it to potential users. It can be extended to…