[Book] Programming Rust
Last Update:
Word Count:
Read Time:
El libro
Introduction
This article is used to keep notes and summaries of the book “Programming Rust”.
The content will be continuously updated as I read through the book.
Reflection
Chapter.2 - A Tour of Rust
rustup and Cargo
1 | |
1 | |
1 | |
Rust Functions
1 | |
By default, once a variable is initialized, its value can’t be changed, but placing the mut keyword before the praameters n and m allows our function body to assign to them.
The function’s body starts with a call to the assert! macro, verifying that neither argument is zero. The ! character marks this as a marco invocation, not a function call.
Writing and Running Unit Tests
1 | |
The #[test] marker is an example of an attribute. Attributes are an open-ended system for marking functions and other declarations with extra information, like attributes in C++ and C#, or annotations in Java. They’re used to control compiler warnings and code style checks, include code conditionally (like #ifdef in C and C++), tell Rust how to interact with code written in other languages, and so on.
Handling Command-Line Arguments
1 | |