Use the type keyword to create a readable alias for existing types in Rust.
Use the type keyword to create an alias for an existing type, allowing you to use the new name interchangeably with the original. This improves readability and simplifies complex type signatures.
type Kilometers = u32;
fn main() {
let distance: Kilometers = 100;
println!("Distance: {}", distance);
}
A type alias gives a long or complex data type a shorter, more descriptive nickname. It matters because it makes your code easier to read and reduces the chance of typos when using complicated types. Think of it like calling a friend by their nickname instead of their full legal name.