Expand description

Design Pattern Examples in Rust

Provides 18 examples of the Design patterns spelled out in the book Design Patterns: Elements of Object-Oriented Software, by Gamma, Helm, Johnson, and Vlissides.

(For overviews of the examples plus viewing them in other programming languages, see Design Pattern Examples.)

The main.rs file contains the main() entry point and the machinery to call all the design pattern example functions. The design pattern examples are each implemented in their own sub-modules.

Modules

  • adapter 🔒
    The Adapter design pattern example module
  • bridge 🔒
    The Bridge design pattern example module
  • command 🔒
    The Command design pattern example module
  • composite 🔒
    The Composite design pattern example module
  • decorator 🔒
    The Decorator design pattern example module
  • facade 🔒
    The Facade design pattern example module
  • flyweight 🔒
    The Flyweight design pattern example module
  • The HandlerChain design pattern example module
  • helpers 🔒
    Contains various kinds of helper modules for the Rust adaptations of the Design Pattern Examples.
  • The Interpreter design pattern example module
  • iterator 🔒
    The Iterator design pattern example module
  • mediator 🔒
    The Mediator design pattern example module
  • memento 🔒
    The Memento design pattern example module
  • nullobject 🔒
    The Null Object design pattern example module
  • observer 🔒
    The Observer design pattern example module
  • proxy 🔒
    The Proxy design pattern example module
  • state 🔒
    The State design pattern example module
  • strategy 🔒
    The Strategy design pattern example module
  • visitor 🔒
    The Visitor design pattern example module

Structs

  • Exercise 🔒
    Represents a single exercise or example for a design pattern.
  • Options 🔒
    Represents the command line options provided to the program, if any.

Constants

  • Holds the version of this application as obtained from the embedded option variable.

Functions

  • help 🔒
    Helper function to show usage information for this program.
  • main 🔒
    Main entry point into this example program.
  • Helper function to parse the given options and return the results in the given Options structure. Displays help if requested.
  • Helper function to show just the version of the application.

Type Definitions

  • Action 🔒
    Alias for a pointer to a function that takes no parameters and returns a Result<(), String> (so only the error needs any action taken), using C# as inspiration for the name.