Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Rust tells: unwrap, clone and RefCell to appease the compiler
card 2 of 6
Safe Rust that moves the error to run time
builds on: Silencing the checker: type escapes and suppressions, Error handling idioms across languages
The agent's proxy signal is a clean `cargo build`. All it can see is the compiler's list of borrow errors, and each of these edits is the shortest one that makes an error vanish. rustc's own help text often suggests cloning. Unlike `unsafe`, these edits are ordinary safe Rust, so they don't look like escapes. But each one either moves a check from compile time to run time or changes what the code means. Later cost: panics, runtime borrow failures, updates lost on copies.
Terms on this card
- cargo build
- The standard Rust command that compiles a project and its dependencies.
- rustc
- The Rust compiler. Its error messages often include 'help' suggestions for possible fixes.
- unsafe
- Rust keyword that permits operations the compiler cannot check, such as raw pointer access; the programmer takes over the guarantee.
- proxy signal
- A visible stand-in for the real goal (tests green, it compiles) that the agent can satisfy without achieving the goal.
- later cost
- The concrete damage a shortcut does after merge: hidden bug, data corruption, maintenance burden.
Lesson goal: Recognise Rust-specific shortcuts: `.unwrap()`/`.expect()` on fallible paths, `.clone()` scattered to dodge borrow errors, and `Rc<RefCell<_>>` or `Arc<Mutex<_>>` used where ownership needed redesigning. Explain the panics and runtime borrow failures these trade for a clean compile. ·
the whole lesson