Shipping modern frontends is harder than it looks. Learn the hidden taxes of today’s stacks and practical ways to reduce churn and avoid burnout.
Learn how native web APIs such as dialog
, details
, and Popover bring accessibility, performance, and simplicity without custom components.
Read about how the growth of frontend development created so many tools, and how to manage tool overload within your team.
Discover what you actually need to build and ship AI-powered apps in 2025, with tips for which tools to choose and how to implement them.
2 Replies to "How to define higher-order functions in Rust"
Thanks for a great article. In python I can pass a method that is bound to an object. Can I do the equivalent in rust?
Hello Giles. A method in Rust is just a function, which also takes a first `self` parameter (similarly to Python). Hence, passing a method is just a matter of using the right types in the function signatures:
pub struct Greeter {
greeting: String
}
impl Greeter {
fn greet(&self, name: String) -> String {
return format!(“{}, {}”, self.greeting, name);
}
}
fn call(name: String, fun: fn(&Greeter, String) -> String) -> String {
let greeter = Greeter { greeting: “Hello”.to_string() };
return fun(&greeter, name);
}
fn main() {
println!(“{}”, call(“Giles”.to_string(), Greeter::greet));
}