Skip to content

RS-LIFE0001 · examples

These examples come directly from RS-LIFE0001. Read their source.

fn name<'a>(&'a self) -> &'a str { ... }
fn width<'a>(text: &'a str) -> usize { ... }
fn name(&self) -> &str { ... }
fn width(text: &str) -> usize { ... }
A lifetime that survives is one elision would get wrong, such as
`fn pick<'a>(&self, other: &'a str) -> &'a str`, where the elided output would borrow from
`self` instead, or `fn descend<'a>(node: &'a Node, found: &mut Vec<&'a Node>)`, where both
inputs have to name one lifetime for the body to compile at all.