Review the Rust that your AI agent wrote
For developers with many years of Java or .NET who now review Rust that an AI wrote.
This site teaches you to read Rust, find the usual mistakes in AI-generated Rust, and tell your agent how to fix them.
You already know most of this
Section titled “You already know most of this”Your Java Optional chain has a direct Rust equivalent. In Rust, ? means “if there is no value, return now”.
Java
Optional<String> customerEmail(long orderId) { return findOrder(orderId) .flatMap(order -> findCustomer(order.customerId())) .map(Customer::email);}Rust
pub fn customer_email(&self, order_id: u64) -> Option<&str> { let order = self.find_order(order_id)?; let customer = self.find_customer(order.customer_id)?; Some(&customer.email)}The Rust version has no null and no exception. The return type Option<&str> tells you that there can be no email, and it borrows the email instead of copying it.
Three questions on every page
Section titled “Three questions on every page”What am I looking at?Read the code at a high level, from the Java concept that you know.
Is this normal?Recognize idiomatic Rust, and the Java habits that AI agents copy into it.
Is this a problem?Judge the code with a checklist and a catalogue of common smells.