INNER CODE UNIT · Rust

body_lifetime_is_tied_to_input

ShurikenTrade/shuriken-skills · src/frontmatter.rs:85

    fn body_lifetime_is_tied_to_input() {
        const STATIC_INPUT: &str = "---\nname: foo\ndescription: bar\n---\n\nbody\n";
        let parsed = parse(STATIC_INPUT).unwrap();
        // This compile-time check locks in the invariant that body borrows
        // from `raw`: if parse ever starts returning an owned String, this
        // will fail to compile because you can't coerce String to &'static str.
        let _static_body: &'static str = parsed.body;
    }
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…