What Is in the Rust Prelude and Why?

The Rust prelude automatically imports common types and functions like String and Vec into every program to reduce boilerplate.

The Rust prelude is a set of standard library items automatically imported into every Rust program, so you don't need to write use statements for them. It includes common types like String, Vec, and Option, traits like Clone and Display, and functions like print! and println!.

// No 'use' needed; String, Vec, and println! are in the prelude
let greeting = String::from("Hello");
let numbers = vec![1, 2, 3];
println!("{}", greeting);

If you need something not in the prelude (like std::fs::read_to_string), you must import it explicitly with use.