The Rust web frameworks axum, actix-web and the game engine bevy use a language pattern to set / register seemingly any function to be passed in as an argument. This pattern is also sometimes known as magic function parameters. Rest assured it's not magic, but rather a neat use of traits and the static type system of Rust to make that happen.

The main goal of this article is to build a good understanding how this pattern works, what its building blocks are & also to show how you can implement it for your own purposes.

Read More >