about
Rust Track Summary
7/04/2024

Rust Track Summary

Story, Bites, and Repositories

Site Explorer Rust Story code Rust Bites code
click header to toggle Rust Explorer
Story Index Prologue Introduction Models Models of structure and semantics Data Types & instances Operations Callable objects Structures Class structure Libraries Standard libraries References Resource links    
Bite Index Introduction Motivation Starting Samples and ideas Tooling VS Code, dev flow Safety Compiler enforcements Undef Behavior Causes Data Types, instance semantics FlashCards Type diagrams Facts Summary of types and basic ideas Strings String, str, other string types Data Structs Data structures Smart Pointers Box, Rc, Arc, RefCell LifeCycle Construction to Destruction Ownership Single ownership, borrowing Generics & Traits Definitions, examples Functions Functions and closures Structs Methods & Traits LifeTime Guarantee no dangling refs Abstractions Domain specific types Enumerations Collecting related types, matching Error Handling Result, bubbling Options Representing Some or None Conversions Converting between compatible types Collections Type diagrams Iterators Iterating over collections Idiomatic Code Clippy & API guidelines Macros Declarative macros Threads Threads, sharing, interior mutability Sync Thread synchronization with locks Channels Sending messages between threads Regular Expressions Using regex crate, string matching Hacks & Helpers Thread helpers, Date & Time Code Experiments Experimenting in playground Playground Examples Motivation Glossary Glossary of Rust terms    
Figure 1. Rust demo code
"What I have been learning ... was not Rust in particular, but how to write sound software in general, and that in my opinion is the largest asset that the rust community taught me, through the language and tools that [they] developed."
- Jorge Leitao on rust-users

There are five ways of viewing Rust content in this site:
  1. Bits devoted to Rust
    Small programs that illustrate HelloWorld, Data, Objects, Generics, and Iteration.
    The fastest way to get a good mental model for Rust programming.
  2. Rust Story
    An ebook with seven chapters that covers Rust programming at intermediate level.
  3. Rust Bites
    A large collection of pages each focused on one feature of the Rust programming language.
  4. Blogs
    Most of the recent blogs focus on Rust specifics, with fairly complete coverage of a single topic in each.
  5. Rust Playground code examples
    Table of links to a collection of basic to intermediate code examples running in Rust Playground.
It's easy to sample each of these views by using the links above, or more selectively, using links in the RustExplorer panel on the left (if you don't see it, click on page header).
What I like about Rust
The Rust language has some very interesting ideas about building memory and data-race safe programs. Program source compiles to native code and runs directly in the process created for it. Its safety mechanisms, enforced at compile-time, make getting started slower than for some other languages, but the compiler error messages are very good, making learning much easier as long as you understand Rust's basic models. Rust Highs and Lows

The code above on the right illustrates a Rust "Hello World" function, often the first thing you encounter when learning a new language. This page is focused on pointing to discussions of Rust models and code examples. It has most of the things you will need to start Rust programming quickly.

Table 1. Rust Resources from this site

Site Resources Content
Rust Repositories Index of all the Rust code repositories
Rust Models Summary of features with screenshots and examples - pdf
Rust Story
Index at upper right on this page.
Rust ebook in 7 chapters
first chapter in Rust Story
Rust Bites
Index at upper right on this page.
Dozens of Code Bites about Rust
first Rust Bite <-- good place to go after this page
Rust Glossary Definitions of common terms
Rust FlashCards Basic types and data structures
Bits of Code Compares small C++, Rust, C#, Python, and JavaScript codes  
Rust Playground online compiler
Code Examples Content
Rust Repositories Index into Rust Repositories
Rust Code examples List of RustBites code examples, RustPlayground code examples, Rust Basic Demos Repository
online code execution RustPlayground, tutorialspoint
Other Resources Content
Rust Guide Definition and examples of Rust collections, iterators, and concurrency constructs.
Tooling Using Visual Studio Code to create and build Rust code
Rust home site Download and install, learn Rust
Rust user's forum Create an account and you can log-in, read, and post messages and questions.
The Rust Reference Semi-formal, but surprisingly readable, reference for Rust
Rust API Guidelines Guidelines for crafting Rust code, from the source
Other intermediate and advanced resources
How to learn modern Rust A collection of links to explorations of intermediate and advanced language materials
idiomatic rust resources Annotated links to articles and examples of community accepted styles and patterns for rust code.
 
You can find videos covering some of the topics in Table 1. and Table 2. using the "Videos" link in the top menu. First Rust Bite is a good next step after this page.

Exercises

  1. Write a Rust program to find the largest file in a specified directory tree, using walkdir crate from crates.io.
  2. Ammend Project #1 by accepting arguments from the command line, using args crate.
  3. Use ChatGPT to create a directory traversal crate and use that instead of walkdir.
  4. Write a Rust program to read a source code file and count the number of lines and number of scopes for each function. You can count scopes by counting open braces "{". Start by searhing for fn and then read each line searching for "{" and "}". Push each open brace on a stack, and pop when a closed brace is encountered. When the stack is empty, the end of the function has been reached.
  5. Modify Project #4 by counting lines and scopes for each file in a directory tree rooted at a specified folder, usually named "src".
  Next Prev Pages Sections About Keys