Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Warm-up: Three Review Calls

From here on we assume yesterday’s vocabulary. Three snippets. For each one: name the smell, the principle behind it, and the one-sentence prompt you’d send.

1

let cfg = config.clone();
apply(&cfg);

2

pub fn parse(s: &str) -> Config {
    let port = s.trim().parse().unwrap();
    Config { port }
}

3

// `status: String`, and this comparison appears at four call sites:
if status == "ready" {
    start_capture();
}