I'm not within reach of the rust compiler, so forgive the broken code.
On the functional side of things, you can create a structure that contains three functions and call them
struct Execution { before: @fn() -> bool, during: @fn() -> bool, after: @fn() -> bool } fn execute (e: Execution) -> bool { ... }
but as soon as you have a function as the value of the first class, you can pass say, a list of logical functions that need to be checked instead of fixed three, or something else depending on what you are trying to achieve.
On the rust side of things, you can make it more “object oriented” using traits
trait Executable { fn execute(&self); } impl Execution { fn execute(&self) { ... } }
source share