Giter Site home page Giter Site logo

rust-design-pattern's Introduction

Rust Design Patterns

Creational Patterns

Pattern Description Status
Factory Method Defers instantiation of an object to a specialized function for creating instances
Abstract Factory Provides an interface for creating families of releated objects
Builder Builds a complex object using simple objects
Singleton Restricts instantiation of a type to one object

Behavioral Patterns

Pattern Description Status
Strategy Enables an algorithm's behavior to be selected at runtime
State Encapsulates varying behavior for the same object based on its internal state
Command Converts requests or simple operations into objects.
Iterator Lets you traverse elements of a collection without exposing its underlying representation
Observer Allows one objects to notify other objects about changes in their state.
Chain of Responsibility Avoids coupling a sender to receiver by giving more than object a chance to handle the request

Structural Patterns

Pattern Description Status
Adapter allows objects with incompatible interfaces to collaborate.
Decorator Adds behavior to an object, statically or dynamically
Proxy Provides a surrogate for an object to control it's actions

rust-design-pattern's People

Contributors

allaeddineattia avatar casonadams avatar lpxxn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-design-pattern's Issues

observer pattern restricted to ConcreteObserver struct instead of IObserver trait

Hi,
I like your patterns very much btw., I needed the Observer Pattern (which doesn't consume like yours) and tried a little but needed one which can have not only have a ConcreteObserver but also AnotherConcreteObserver, which I think fits more to the purpose.
Since I didn't need detaching, I didn't have the identifying problem when detaching, and came up with a version which uses box and dyn, and no partialeq.
I am intermediate in Rust, I'd say, so I explain best with that.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=5115d33f36e98f73611e1b979988d0f4

I even tried a little with detach, which I believe you have to kind of first find out if the dyn type matches (don't know how) and then use the partialeq trait on the concrete type like you did. Because I also had trouble with the trait itself, dyn, box, box dyn, &? in trait alone, I stopped here (I don't need detach), and I believe it could be interesting to you.

Non-OO patterns

Understood that design patterns were about OO only in the early days, whilst I believe it could extend beyond OO to other paradigms, e.g. functional, procedural, symbolic, etc. Would it be considered possible in the future?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.