Actix-web: What is the difference between wrap and wrap_fn?


I'm trying to make my own middleware.
However, I am thinking of using wrap_fn because the method of creating middleware is difficult.
What is the clear difference between wrap and wrap_fn?
Also, will the performance be worse if I use wrap_fn?

wrap is used when you implement your middleware on a struct. wrap_fn is used when you implement the middleware with a closure.

Link to documentation: App in actix_web - Rust

I have already read that document.
Other than that, is there any difference, especially in terms of functionality?
If not, I would like to use wrap_fn.

The only difference worth mentioning is that of reusability. If you implement a middleware on a struct, you can use it in several routes throughout your application; if you implement it with a closure, it will only apply for that specific route.

I will refer to.
Thank you!