about
11/29/2022
RustBasicDemos Repo
RustBasicDemos code

RustBasicDemos  Repository

Practice code - Rust code index

Quick Status Code functions correctly no known defects Demonstration code yes Documentation yes Test cases Yes, for Display library Static library none planned Build requires Rust installed Planned design changes Add many more examples

Contents:

Basic demos for Rust syntax: Some of these demos develop examples used in the Rust Story and will eventually be moved to their own RustStory repository. The others are explorations I made while learning rust.
  1. code_structure_demo
    Demonstrates building an application out of several packages, one of which provides a trait interface and object factory. That allows the other packages to avoid binding to its implementation details.
  2. data_types
    Basic demos for ints, floats, char, bool, unit, arrays, tuples, Strings, structs, enums, Vecs, and HashMaps
  3. demo_library
    Hello world library to show how applications can use modules and libraries.
  4. demo_test
    Shows how to load Hello World library package and import local hello module.
  5. display library
    Provides display helper functions and a log function that displays type and value of supplied variable.
  6. display_test
    Tests display operations and also shows how to import local crate (display).
  7. enum_probes
    Example use of enumerations and matching.
  8. error_probes
    Using Option<T> and Result<T, E> enumerations.
  9. file_io
    Illustrates reading from files. Will add file writing soon.
  10. function_probes
    Demonstrates pass by value and reference, passing functions as arguments.
  11. generics_probes
    Illustrates generic functions and structs.
  12. iterator_probes
    Iterator and iterator adapter example use.
  13. lambda_probes
    Examples of closure uses.
  14. logger
    First example of a fairly complete application.
  15. rust_modules
    Demonstrates how to assemble a crate and external modules it depends on.
  16. rust_probes - small, getting started demos. First code I wrote in Rust to learn the language basics.
    • dblformats - shows how to format double precision numbers
    • debugformats - illustrates what debug formats {:?} do for each of the Rust types
    • demodrop - first take on ownership
    • env_probe - extract and display command line
    • formatstructure - various ways to use the format specifiers
    • ownership - thorough walkthru of ownership: copy, move, and references (borrows)
    • point_traits - explores using traits with generic structs, static and dynamic dispatching
    • probe_structs - ownership and traits
    • probe_traits - explore using traits as interfaces and generic type constraints
    • probe_unsafe - quick peek at unsafe blocks and use of safe pointers
    • types - complete illustration of declaration specifiers for each of the Rust types then contrasts with type deduction
  17. string_probes
    Indexing is an issue for Rust Strings since char type is utf8, e.g., variable size characters. Note that indexing strings of utf8 chars is inherently order n.
  18. struct_probes
    Using structs as types with methods and traits.
  19. vector_probes
    A few simple demos of vectors and ownership.

Build:

This Rust code was built with Cargo from Visual Studio Code terminal and tested on Windows 10.

Status:

There is some overlap of demo code in these examples. I will refactor once the Rust Story is complete.
  Next Prev Pages Sections About Keys