Generic Data Types

You can use generics to abstract over the concrete field type:

  1. #[derive(Debug)]
  2. struct Point<T> {
  3. x: T,
  4. y: T,
  5. }
  6. fn main() {
  7. let integer = Point { x: 5, y: 10 };
  8. let float = Point { x: 1.0, y: 4.0 };
  9. println!("{integer:?} and {float:?}");
  10. }