Rust语言之GoF设计模式:Visitor访问者游客模式
的类型进行匹配。 trait Data {
fn accept<V: Visitor>(&self, visitor: &mut V) ->
1 年 前
Python中self类似Java中是this吗?
在 Python 中,self 类似于 Java 中的 this。
Python 中的 self 和 Java 中的 this 都是对调用方法的对象实例的引用。
在 Python 中
3 个月 前
Rust中Builder轻量模式
self, position: Vec3) -> Shape {
self.position = position;
self
}
pub fn
1 年 前
Python Clean Code提示:不要添加冗余上下文
:
__init__(self, person_first_name, person_last_name, person_age):
self.person_first_name
2 年 前
使用EventStoreDB实现事件溯源的Python开源项目
(Application):
def register(self, name):
dog = Dog(name)
self.save(dog
1 年 前
Rust语言之GoF设计模式:备忘录Memento模式
Memento允许制作对象状态的快照并能在以后恢复这些状态。 trait Memento<T> {
fn restore(self) -> T
1 年 前
Rust语言之GoF设计模式:桥Bridge模式
use radio::Radio;
pub use tv::Tv;
pub trait Device {
fn is_enabled(&self) -> bool
1 年 前
Rust语言之GoF设计模式: 模板方法模式
template_method(&self) {
self.base_operation1();
self.required_operations1
1 年 前
使用Rust语言实现帕斯卡三角
PascalsTriangle {
pub fn new (row_count: u32) -> Self {
Self { rows: Self::create
1 年 前
Clean Code书籍中java与Python版本的示例 - Code Review
Python版本: class GuessStatsMessage:
def __init__(self, candidate, count
3 年 前
Rust中在Trait实现中定义常量值
get_value(&self) -> i32 {
Self::DEFAULT_VALUE
}
}
struct MyStruct;
impl MyTrait for
3 个月 前
Rust语言之GoF设计模式:工厂模式
{
fn render(&self);
fn on_click(&self);
}
/// Dialog有一个工厂方法`create_button
1 年 前
Python中的Getter和Setter -GeeksforGeeks
use
# of get() and set() method in
# normal function
class Geek:
def __init__(self
3 年 前
Rust语言之GoF设计模式:状态模式
State {
fn play(self: Box<Self>, player: &mut Player) -> Box<dyn State>
1 年 前
Python中的发件箱模式源码
:
def __init__(
self,
library_card_repository: ILibraryCardRepository
1 年 前