fn main() { let xs=vec![1_i64,2,3,4]; trait Describe { fn describe(&self) -> String; } impl Describe for i64 { fn describe(&self) -> String { format!("int {self}") } } impl Describe for f64 { fn describe(&self) -> String { format!("float {self}") } } impl Describe for [i64] { fn describe(&self) -> String { format!("{} ints, first {}", self.len(), self[0]) } } fn describe(x: &T) -> String { x.describe() } println!("{}; {}; {}; {}", describe(&7_i64), 2.5_f64.describe(), xs.describe(), describe(&xs[2..])); }