Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

design-patterns-rust

> 设计协作
Open source

Rust examples for all 23 classic GoF design patterns, and even a little more

1.1K stars0 likes0 views
WebsiteGitHub

About

Rust examples for all 23 classic GoF design patterns, and even a little more

Design Patterns in Rust

This repository contains Rust examples for all 23 classic GoF design patterns, and even a little more.

All examples are designed to introduce practical applicability in the Rust language. There are conceptual and real-world examples. In both cases, Rust idiomatic ways of code development and all the specifics are taken into account.

The repository is developed to be a part of the Refactoring.Guru project.

Requirements

These examples have been tested with a stable rustc 1.82 (2021 edition).

All examples can be launched via the command line, using cargo as follows:

bash
cargo run --bin adapter

Each target name can be found in Cargo.toml of each example:

toml
[[bin]]
name = "adapter"
path = "main.rs"

Also, the examples contain a README.md with instructions and additional explanations.

✅ List of Examples

…

Some examples have visual output.

Flyweight State Command

Notes

Interestingly, in Rust:

  1. Almost all structural and creational patterns can be implemented using generics, hence, static dispatch.
  2. Most behavioral patterns can NOT be implemented using static dispatch, instead, they can be implemented only via dynamic dispatch.

A well-thought pattern classification fits the Rust language design perfectly as "behavior" is dynamic in nature and "structure" is static.

Some patterns are really easy to implement in Rust, mostly creational ones, e.g. Prototype, Static Creation Method.

The Mediator behavioral pattern is the hardest to implement with Rust, considering Rust's specific ownership model with strict borrow checker rules.

License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Credits

Authors: Alexander Fadeev (@fadeevab).

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustdesign-patternsrust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category设计协作
PricingOpen source

> Related tools

F
Figma
协作式界面设计工具
S
sketch-wakatime
Sketch plugin for automatic time tracking and metrics generated from your Sketch usage.
Q
QuickColor
Quickly apply fills from the global or document color palettes to selected elements - 🎨