Rust · Concept
Generics
Rust generics let one function or type work with multiple concrete types. Declare type parameters inside angle brackets, commonly using names such as T, to reduce duplicated code.
Last updated
Syntax
fn foo<T>(arg: T) { ... }
struct SingleGen<T>(T);In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
Option<T>Vec<T>HashMap<K, V>Result<T, E>type parameters