April 2026
Intermediate
631 pages
16h 20m
English
In this section, we’ll explore the Sized trait, which is automatically implemented at compile time for types of a known size. We’ll also look at the optional Sized trait, which is useful for handling types that may or may not have a fixed size.
The first point to note about the Sized trait is that it serves as both an auto trait and a marker trait. Let’s quickly recap auto traits and marker traits, which we introduced in Chapter 8, Section 8.2.7 and Section 8.2.8, respectively.
Auto traits are traits that are automatically implemented for a type if certain conditions are met. Marker traits, on the other hand, indicate that a type has a specific property. All auto traits are marker traits, which means ...
Read now
Unlock full access