topic: lifetimes
lifetimes are rust-only -- no python equivalent. they let the compiler verify
that borrowed references don't outlive the data they point to.
concepts to demonstrate
- lifetime annotation syntax:
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str
- struct fields with lifetime parameters
- the borrow checker: why rust catches use-after-free at compile time
'static lifetime
patriots theme
ScoutReport<'a> struct holding a reference to a Player from the roster vec.
function returning the player with the longer career that borrows from two slices.
file
src/lifetimes/scout_report.rs
note
this module has no python equivalent. use it to show what rust gives you that python can't.