學習了一下 Rust 語言,不像人們說的學習曲線很高,為了練手,用 Rust 把常用的設計模式實現了一遍,就當。
github 地址: https://github.com/lpxxn/rust-design-pattern
目前實現的有,會持續更新:
序號 | 模式 & 描述 | 已經實現的模式 |
---|---|---|
1 | **創建型模式 ** 這些設計模式提供了一種在創建對象的同時隱藏創建邏輯的方式, 而不是使用 new 運算符直接實例化對象。 這使得程序在判斷針對某個給定實例需要創建哪些對象時更加靈活。 |
工廠模式(Factory Pattern) [抽象工廠模式(Abstract Factory Pattern)](Abstract Factory) 建造者模式(Builder Pattern) 單例模式(SingletonPattern) |
2 | 行為型模式 這些設計模式特別關注對象之間的通信。 |
策略模式(Strategy Pattern) 狀態模式(State Pattern) 命令模式(Command Pattern) 迭代器模式(Itera tor Pattern) 觀察者模式(Observer Pattern) 責任鏈模式(Chain of Responsibility Pattern) |
3 | 結構型模式 這些設計模式關注類和對象的組合。繼承的概念被用來組合接口和定義組合對象獲得新功能的方式。 |
適配器模式(Adapter Pattern) 裝飾器模式(Decorator Pattern) 代理模式(Proxy Pattern) |