Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions behavioral/template-method/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Same client code can work with different concrete implementations:
TemplateMethod says: I am doing the bulk of the work
ConcreteStruct2 says: Implemented Operation1
TemplateMethod says: But I let subclasses override some operations
ConcreteClass2 says: Overridden Hook1
ConcreteStruct2 says: Implemented Operation2
TemplateMethod says: But I am doing the bulk of the work anyway
```
4 changes: 4 additions & 0 deletions behavioral/template-method/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ impl TemplateMethod for ConcreteStruct2 {
fn required_operations2(&self) {
println!("ConcreteStruct2 says: Implemented Operation2")
}

fn hook1(&self) {
println!("ConcreteClass2 says: Overridden Hook1")
}
}

fn client_code(concrete: impl TemplateMethod) {
Expand Down