Genericity is the capacity to write code once, without or partly specified types, so that the code can be used for many different types. Rust has this capacity in abundance and applies it for both data structures and functions.
A composite data structure is generic if the type of its items can be of a general
T can be an
String, or a
struct type such as
Person that we coded ourselves. So, we can have not only
Vec<f64> but also
Vec<Person>. If you make
T a concrete type, then you must substitute
T with that type everywhere
T appears in the definition of the data structure.
Our data structure can be parametrized with a generic
<T> type, so it has multiple concrete definitions—it is polymorphic. ...