ABSTRACT

This chapter discusses generic data types, traits: defining shared behavior, and validating references with lifetimes. Generics can define items such as function signatures or structs, which can then be used with various concrete data types. A trait informs the Rust compiler about the functionality that a given type has and can share with other kinds. In an abstract sense, traits can be used to define shared behavior. Trait boundaries can define a generic type as any type with the specific behavior. The concept of lifetimes is separate from other programming languages' tools, and it is perhaps Rust's most distinguishing characteristic.