Open simonsan opened 3 years ago
I donno if relevant but one can simulate a reasonable degree of simple local inheritance without overloading by using inherent methods on a parent types whose subtypes are specified using type parameters https://github.com/rust-lang/rfcs/issues/349#issuecomment-733204959 so generic methods on the polymorphic base become available to all children. In practice, one often needs sealed traits once this gets heavier, so then maybe a true trait interface makes sense, but sometimes the situation is quite simple.
@simonsan Strategy pattern: https://medium.com/swlh/strategy-design-pattern-in-rust-5f5486cd294c I can add it here.
Nice, for sure! 💯
Today I discovered https://github.com/udoprog/patterns where game engine patterns
are collected and I was wondering if that might be a good idea to add these patterns in this repository. I opened an issue to discuss this and see what is the general stance on it over at udoprog/patterns
: https://github.com/udoprog/patterns/issues/1
Something new to addon for cell if anyone work on cell. https://plv.mpi-sws.org/rustbelt/ghostcell/
Collection of design patterns and the corresponding issues if not contained in the repository already (in reference to Design patterns (by Gamma, Helm, Johnson, Vlissides)). Some patterns are probably not applicable to/realizable with Rust as they stem from OOP, but we'll sort that out on the way.
But in general I think it is also nice to have
design patterns
listed somewhere on a page that are not applicable to Rust and stated why and with an added workaround if any.Coverage
Patterns
Creational Patterns
Structural Patterns
Behavioural Patterns
Still Uncategorized
libstd
, and how it integrated into the Rusts source code, lessons can be learned about ergonomic project management and API design. Closely assosciated with platform-specific sub-modulesError
traits andResult
forwardingIdioms
Anti-patterns
Unwrap()
ing everyResult
instead of forwarding itFunctional Programming
Refactoring
unwrap
toResult
General Unsorted
Notes
35: I recently started collecting some API design patterns here. I'm not sure if these match what this repo is all about (or which ones you already cover), but I just wanted to say: Feel free to take anything you like from that post! :)
The markdown source of that post is here and I hereby relicense the content as MPL2 (in addition to CC-BY) and allow you to use it in this repo.
From Reddit
Pre-Pooping Your Pants
Rooting an Rc handle
Precise closure capture clauses
Iterating an over a Rc<Vec<T>>
https://users.rust-lang.org/t/blog-post-series-rust-patterns/20080/10
Push Ifs Up And Fors Down
If a Tree Falls in a Forest, Does It Overflow the Stack?
Destructing trees safely and cheaply
Builder Lite
Caches In Rust
Inline In Rust
Newtype Index Pattern
Typed Key Pattern
Encapsulating Lifetime of the Field
Break on named blocks
Temporarily opt-in to shared mutation
Actors with Tokio