INNER CODE UNIT · Rust
no_frontmatter_is_error
ShurikenTrade/shuriken-skills · src/frontmatter.rs:79
fn no_frontmatter_is_error() {
let raw = "just a body with no frontmatter";
assert!(parse(raw).is_err());
}
#[test]
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;
}
}