Wyzer

We can see through others only when we can see through ourselves.

— Bruce Lee

Generics and Traits

NAME wyzer-generics - Polymorphism and shared behavior

DESCRIPTION Generics permit functions and structures to operate over multiple types. Traits define shared behavioral contracts.

SYNOPSIS: GENERICS

struct Point<T> {
    x: T,
    y: T,
}

fn identity<T>(value: T) -> T {
    value
}

fn main() {
    let p1 = Point<u32> { x: 10, y: 20 };
}

GENERICS DETAILS

  • <T>: Type parameter declaration.
  • Instantiation: Concrete types (e.g., u32) are provided during instantiation or inferred by the compiler.

SYNOPSIS: TRAITS

trait Summary {
    fn summarize() -> str;
}

TRAITS DETAILS

  • trait: Declares a collection of method signatures that implementing types must define.

© 2026 Wyzer Contributors

Edit this page on GitHub