The prelude crate

One of the things I really miss about langauges like python is that you don't have to clutter your import space in order to use most functionality.

That is not true with rust.

In rust, I frequently find myself writing "" modules to import structs and traits that are necessary in practically every file in my project.

To alieviate this, I have created the prelude crate:

It can be used like:

extern crate prelude;
use prelude::*
// You can now use HashMap, etc!

This crate was basically put together because of the number of times I write a line of code and then hit compile and see that it doesn't work because of a forgotten import. It is quite annoying to not have access (by default) to std functions like from_iterator or write_str because you forgot to import a trait! It is almost as frustrating to be using a HashMap and realize it isn't defined. This is especially frustrating for newbies, so I see this lib as a possible (and effective) workaround.

I have created a survey here and would love everyone's input on what should and shouldn't go in the crate:

I would really love feedback! Thanks!

1 Like

I like the idea but, FYI, a lot of those traits are already in the prelude. Also, you might want to consider re-exporting the io prelude.


apparently naming your crate things like prelude is risky buisness, found an ICE during doctests when using it....

just goes to show you -- always run tests before shipping, no matter how simple you think it is.

I think this is a worthwhile experiment. Thanks for doing it.