3 ms·
You can absolutely curry functions in Rust. You just have to do it manually because there's no syntactic sugar for it. I think that's a good thing. A curried f
by bunderbunder 1y ago
You can absolutely curry functions in Rust. You just have to do it manually because there's no syntactic sugar for it.
I think that's a good thing. A curried function is a function that takes one argument, and returns a closure that captures the argument. That closure might itself take another argument, and return a new closure that captures both the original argument and the second one. And so on ad infinitum. How ownership and borrowing works across that chain of closures could easily become a touchy issue, so you probably want to be making it as explicit as possible.
Or perhaps better yet, find an easier way to accomplish the same task. Maybe use a struct to explicitly carry the arguments along until you're ready to call the function.