In this section, we'll look at some of the advanced types in Rust. Let's first start with unsized types.
Advanced types
Unsized types
Unsized types are categories of types that are first encountered if one tries to create a variable of the type, str. We know that we can create and use string references only behind references such as &str. Let's see what error message we get if we try to create a str type:
// unsized_types.rs
fn main() {
let a: str = "2048";
}
We get the following error upon compilation:
By default, Rust creates a reference type of str as 'static str. The error message mentions that all local variables—values that live on the stack—must have a statically...