The Rust Prelude

braindead
Aug 13, 2022

--

In rust Prelude can be of 2 types:

  1. The Prelude
  2. Other Prelude

The Prelude

A 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 Prelude

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.

--

--

braindead
braindead

Written by braindead

A passionate programmer, I am eager to challenge myself to do things I’ve never accomplished before and I strive to learn and improve on my skills every day

Responses (1)