about
RustStory Prologue
6/8/2022
RustStory Prologue
Getting started
- Katharine Hepburn
0.0 Getting Started
- Crates and Modules are the building blocks for Rust programs. They are housed in packages created by Cargo, the Rust package manager.
- Data is, by default, immutable. You use the mut keyword to allow a variable to be modified.
- Ownership of data - each value has only a single owner, but ownership can be tranferred. Also, code can borrow a view of the data without transferring ownership by constructing a reference or a slice.
- Traits are similar to interfaces or abstract classes and support polymorphic operations. They are frequently used to bound the set of types allowed as type parameters for a generic type.
0.1 Primary Links
Link | Description |
RustModels.pdf |
Slide presentation: Type safety, Rust ownership, object model, generics, code structure |
Code for RustModels | Slides present a number of code fragments. These are the complete programs. |
References | Things to read and view for more details |
This story | Models, Data, Operations, Objects, Libraries |
Code for this story | Complete program sources for code fragments in the story |
RustBasicDemos | Repository of code demonstrations, many written to explore Rust |
-
Basic Rust Knowledge:
This story provides some of what you need, along with code examples in the RustBasicDemos repository. Also see the references at the end of this page. -
Rust Tool Chain:
For any environment, download Rust tools. This gives you Cargo , the Rust package manager, andrustc , the Rust compiler. This is all the tooling you need to start.Visual Studio Code
Rust doesn't come with an IDE, butVS Code gives you a text editor with a terminal pane, from which you enterCargo commandsbuild ,run ,clean , and more.You will want to install the VS Code plugin Rust (rls) which gives you some syntax highlighting and code completion.The VS Code model expects you to use JSON files to configure build and debug launchers. I have found that occasionally hard to use, and often requires more effort to configure that I am willing to spend on this tool. Working in the code editor and launching Cargo commands in the terminal works well for me. For Windows I use the default PowerShell terminal. You can replace that with the Windows CMD terminal if you wish. On linux the default bash terminal works well. -
Now start:
Download the RustBasicDemos. Open VS Code and open one of the folders in RustBasicDemos, then Cargo build andCargo run in the terminal. You should see output in the terminal.
0.2 Contents
-
Prologue
Getting started. -
Rust Models
Key ideas and background needed for later chapters. -
Data
Types provided by Rust, usage, collection demos. -
Operations
Functions, methods, std library facilities -
Structs
Objects, Traits -
Libraries
Several of the most often used libraries are discussed and code examples provides. -
References
Quite complete set of references for the Rust Programming Language
0.3 References:
Reference Link | Description |
---|---|
Rust (Programming Language) - Wikipedia | Well written summary of the Rust language. |
Considering Rust - Feb 2020 - Jon Gjengset | Great what-is-it video, with code snippets and a lot of mind setting conversation by a very knowledgable presenter. |
intorust.com | A few short screen casts - Nicholas Matsakis, ... |
readrust.net/getting-started | Nice set of "first-look" posts. |
rust-learning repository | Extensive list of resources: books, videos, podcasts, ... |
A half-hour to learn Rust | Code fragments with commentary that cover most of the Rust ideas. |
A Gentle Introduction To Rust | A good walkthrough most of the Rust ideas. |
The Rust Programming Language | Long but gentle walkthrough of the Rust Language |
An alternative introduction to Rust | Steve Klabnik |
Rust pain-points | Steve Donovan |
Rust by Example | Rust docs - walkthrough of syntax |
Getting Started with Rust on Windows and Visual Studio Code | Install Rust, Verify, Configure Visual Studio Code, Create Hello World, Create Build Task, Configuring Unit Tests, Configure Debugging, |
rust-lang.org home page | Links to download and documentation |
rust cheat sheet | Quite extensive list of cheats and helpers. |
More References | Basic, intermediate, and advanced references |