Module serde::lib::core::prelude

1.0.0 · source ·
Expand description

§The Rust Prelude

Rust comes with a variety of things in its standard library. However, if you had to manually import every single thing that you used, it would be very verbose. But importing a lot of things that a program never uses isn’t good either. A balance needs to be struck.

The prelude is the list of things that Rust automatically imports into every Rust program. It’s kept as small as possible, and is focused on things, particularly traits, which are used in almost every single Rust program.

§Other preludes

Preludes can be seen as a pattern to make using multiple types more convenient. As such, you’ll find other preludes in the standard library, such as std::io::prelude. Various libraries in the Rust ecosystem may also define their own preludes.

The difference between ‘the prelude’ and these other preludes is that they are not automatically use’d, and must be imported manually. This is still easier than importing all of their constituent components.

§Prelude contents

The first version of the prelude is used in Rust 2015 and Rust 2018, and lives in std::prelude::v1. std::prelude::rust_2015 and std::prelude::rust_2018 re-export this prelude. It re-exports the following:

The prelude used in Rust 2021, std::prelude::rust_2021, includes all of the above, and in addition re-exports:

Modules§

  • The 2015 version of the prelude of The Rust Standard Library.
  • The 2018 version of the prelude of The Rust Standard Library.
  • The 2021 version of the prelude of The Rust Standard Library.
  • The first version of the prelude of The Rust Standard Library.
  • rust_2024Experimental
    The 2024 version of the prelude of The Rust Standard Library.