Lifetime Bounds on Traits
Lifetime Bounds on Traits
Constrain types with lifetime bounds, such as T: 'a (meaning T must outlive lifetime 'a):
use std::fmt::Display;
fn print_ref<'a, T>(item: &'a T)
where
T: Display + 'a,
{
println!("Item: {}", item);
}