simonsan
simonsan
Tracking issue for merging: https://github.com/lpxxn/rust-design-pattern/blob/master/creational/singleton.rs Example: ``` use std::mem::MaybeUninit; use std::sync::{Mutex, Once}; #[derive(Debug)] struct Config { db_connection_str: String, } fn get_config() -> &'static Mutex { static mut CONF: MaybeUninit =...
State
Tracking issue for merging: https://github.com/lpxxn/rust-design-pattern/blob/master/behavioral/state.rs Example: ``` //! State is a behavioral design pattern that lets an object alter its behavior when its internal state changes. //! It appears as...
Iterator
Tracking issue for merging: https://github.com/lpxxn/rust-design-pattern/blob/master/behavioral/iterator.rs Example: ``` //! Iterator is a behavioral design pattern that lets you traverse elements of a collection without exposing its underlying representation (list, stack, tree,...
An example can be found here: https://web.archive.org/web/20210222121044/https://chercher.tech/rust/momento-design-pattern-rust
Examples can be found here: - https://web.archive.org/web/20240310010750/https://fadeevab.com/mediator-pattern-in-rust/ - https://web.archive.org/web/20240328221127/https://www.hackingwithrust.net/2023/04/16/design-patterns-in-rust-mediator-or-uncoupling-objects-made-easy/ - https://web.archive.org/web/20201030072504/https://chercher.tech/rust/mediator-design-pattern-rust
An example can be found here: https://web.archive.org/web/20201029154924/https://chercher.tech/rust/prototype-design-pattern-rust
An example can be found here: https://web.archive.org/web/20201031155022/https://chercher.tech/rust/bridge-design-pattern-rust
An example can be found here: https://web.archive.org/web/20210222115918/https://chercher.tech/rust/composite-design-pattern-rust
Let's collect some ideas first: from #117 * currying * higher-order functions * collections
A small read how to wrap errors when creating a library: https://web.archive.org/web/20210125225615/https://edgarluque.com/blog/wrapping-errors-in-rust Do you think it makes sense to include `wrapping errors` as a pattern? I would ask the initial...