Check out Kiro, AWS’s AI-powered IDE, see what makes it different from other AI coding tools, and explore whether it lives up to the hype.
Here’s how three design patterns solved our Go microservices scaling problems without sacrificing simplicity.
Explore six principled design patterns (with real-world examples) to help you protect your LLM agents from prompt injection attacks.
As AI tools take over more routine coding work, some companies are cutting early-career dev roles — a short-sighted move that could quietly erode the next generation of tech leaders if we aren’t careful.
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));
}