An Example Program Using Structs - The Rust Programming Language
To understand when we might want to use structs, let’s write a program that calculates the area of a rectangle. We’ll start by using single variables, and then refactor the program until we’re using structs instead.
An Example Program Using Structs - The Rust Programming Language Keyboard shortcuts Press ← or → to navigate between chapters Press S or / to search in the book Press ? to show this help Press Esc to hide this help Auto Light Rust Coal Navy Ayu The Rust Programming Language An Example Program Using Structs To understand when we might want to use structs, let’s write a program that calculates the area of a rectangle. We’ll start by using single variables and then refactor the program until we’re using structs instead. Let’s make a new binary project with Cargo called rectangles that will take t
Explore this link on the map →saved by
related reading
- Defining and Instantiating Structs - The Rust Programming Languagedoc.rust-lang.org
- Generic Data Types - The Rust Programming Languagedoc.rust-lang.org
- Methods - The Rust Programming Languagedoc.rust-lang.org
- Defining an Enum - The Rust Programming Languagedoc.rust-lang.org
- Programming a Guessing Game - The Rust Programming Languagedoc.rust-lang.org
- Generic Types, Traits, and Lifetimes - The Rust Programming Languagedoc.rust-lang.org
- A half-hour to learn Rustfasterthanli.me
- Defining Shared Behavior with Traits - The Rust Programming Languagedoc.rust-lang.org
- References and Borrowing - The Rust Programming Languagedoc.rust-lang.org
- Variables and Mutability - The Rust Programming Languagedoc.rust-lang.org
- The Slice Type - The Rust Programming Languagedoc.rust-lang.org
- Rust Language Cheat Sheetcheats.rs