about
      Rust Bite Repo
      07/02/2024
      
      
      Consuming Rust bite by byte Repository
Short bites about Rust features
Quick Status
Bite Index
- Thomas Huxley
Contents:
                I think of these Bites as a work book for the Rust Story.  The story
                provides a fairly complete narrative description of the Rust programming language.
                 
                Each Bite takes an important feature or capability of the language, provides a consise statement,
                an example of its operation, and, for most of the Bites, a short set of exercises designed for
                newcomers to the language.
              
              
            Bites:
- 
                  
Introduction What are RustBites?  - 
                  
Starting Quick references to get the idea, and longer references to learn how to write the code.  - 
                  
Tooling Editing and building Rust - first simple projects, then multi-package projects  - 
                  
Safety Invariants, Ownership, Interior Mutability  - 
                  
Undefined Behavior Examples of undefined behavior using C++  - 
                  
Data Bind, Copy, Move, Clone, and Mutate  - 
                  
Rust Flash Cards Quick view of Rust type system  - 
                  
Rust Facts More type system details  - 
                  
std Data Structures array, tuple, struct, String, Vec, Set, Map  - 
                  
smart pointers Box<T>, Rc<T>, Arc<T>, RefCell<T>  - 
                  
LifeCycle new, Bind, Drop  - 
                  
ownership Mutation, single ownership, borrowing and transfer, RwLock semantics  - 
                  
generics and traits Generic types, contracts, methods, implementing traits, derived traits.  - 
                  
functions Pass by value and reference, accepting and returning other functions.  - 
                  
structs Declarations, members, implementing methods.  - 
                  
lifetime annotations Generic annotations that help compiler ensure that references don't outlive referents.  - 
                  
Abstractions Defining application abstractions, e.g., user defined types, with traits and structs.  - 
                  
error handling Returning results that may fail, matching, bubbling up error events.  - 
                  
Collections std::collections types and user-defined collections.  - 
                  
Iterators Declarative access and mutation of collections.  - 
                  
Idiomatic Rust Declarative access and mutation of collections.  - 
                  
Threads Creation of threads, thread-safe sharing.  - 
                  
Synchronization Serializing access with Mutex, Convar, and Arc.  - 
                  
Channels Moving objects between threads.  - 
                  
async-await Concurrency without creating threads.  - 
                  
macros Defining macros, matching.  - 
                  
RegEx Regular expressions using regex crate from crates.io  - 
                  
Hacks and Helpers Useful ideas and techniques  - 
                  
Glossary of Terms Term, definition, links  
Bite Demonstration Code:
- 
                _Experiments
Demonstration of trait specialization requiring nightly build, e.g., not yet stable Rust. - 
                bite_data_ex1
Verifies copy operation using pointers. - 
                closure_param
Example of function accepting a closure parameter. - 
                closures
Demonstrates closures with copy and with move capture. - 
                data_str
Illustrates use of arrays, structs, strings, vectors, and maps. Also demonstrates use of generic display functions for iterable collections and folded displays. - 
                dispatch
Demonstrates both static and dynamic dispatch for trait functions and trait objects. - 
                exercises
Solutions for three more difficult smart pointer exercises. - 
                functions_and_methods
- 
                    functions
Pass arguments by value and reference, pass and return functions, use static and dynamic dispatch. - 
                    methods
Demonstrate non-generic and generic methods. - 
                    return_values
Illustrate Option<T> and Result<T, E> return values. 
 - 
                    functions
 - 
                generics_and_traits
Demonstrate generic function that accepts generic struct as argument, both constrained by Debug trait. - 
                life_cycle
Creates type with instances that announce their creation, cloning, and drops. Use that to illustrate life cycle for objects in several common scenarios. - 
                modeling
Illustrate building objects that implement traits. Use them to build trait objects and use to demonstrate Object Oriented design patterns that use dynamic dispatching. - 
                ownership
Illustrate some operations that satisfy the Rust ownership model and some that don't with commentary in comments. - 
                point
Defines a SpaceTime trait for points, implements a Point class that implements, and demonstrate how that might be useful. - 
                smartptrs
- 
                    run_time_checking
Demonstrates use of RefCell to provide inner mutability. That enables code to build that is satisfies ownership policy but compiler can't verify. That uses run-time checks implemented with RefCell. - 
                    show_arc
Simple demo of the Arc<T> thread-safe, reference counting, smart pointer. - 
                    show_rc
Simple demo of the Rc<T> smart pointer, non-thread-safe, reference counting, smart pointer. - 
                    show_refcell
Simple demo of RefCell<T> - 
                    test_type
LifeCycle demo type - uses annonciation. 
 - 
                    run_time_checking
 - 
                UndefBehavior
A demonstration of undefined behavior with C++ code. - 
                hacks_and_helps
Collection of useful code fragments and problem solvers:- 
                      atomics
Demos of sharing AtomicBool and AtomicUsize between threads. - 
                      date_time_timer
Create time and data stamps, time program events, and set callback timers. - Illustrates a common problem encountered when writing asynchronous methods, and how to fix it, keeping asynchronous processing intact.
 
 - 
                      atomics