From aa522404bee8301a30203cedeaac4930b3647664 Mon Sep 17 00:00:00 2001 From: enaviaynga Date: Sun, 26 Oct 2025 20:50:24 -0500 Subject: [PATCH 1/2] fix template-method added "hook1" override in ConcreteStruct2 --- behavioral/template-method/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/behavioral/template-method/main.rs b/behavioral/template-method/main.rs index 81e4d87..f073632 100644 --- a/behavioral/template-method/main.rs +++ b/behavioral/template-method/main.rs @@ -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) { From a94b659286384b7e982394d2a19079fa72588bb5 Mon Sep 17 00:00:00 2001 From: "Navia Ynga, Emanuel" Date: Sun, 26 Oct 2025 20:58:24 -0500 Subject: [PATCH 2/2] Fix output template-method add hook1 message --- behavioral/template-method/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/behavioral/template-method/README.md b/behavioral/template-method/README.md index 8551eed..03da7dd 100644 --- a/behavioral/template-method/README.md +++ b/behavioral/template-method/README.md @@ -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 ```