Preludes? #140
Replies: 1 comment
-
There are definitely some APIs—especially for things like testing libraries or Personally, I'm rather fond of glob imports for cases like these, because otherwise I have to spend a lot more time digging around in the docs and figuring out errors just to get things done. Yes, I understand that in some sense it's not "ideal", because a new export might someday be added to the glob and conflict with some other import. But that's absolutely a risk I'm willing to pay in the name of convenience for certain carefully-chosen APIs. I do have a rule of "no glob imports for things which aren't preludes", though. That seems pretty sensible. |
Beta Was this translation helpful? Give feedback.
-
In general, it seems that the usage of glob imports (
use foo::*;
) is generally discouraged in Rust [1], while at the same time the std lib and some other crates offer "prelude" modules [2] that users are supposed to glob import for convenience.Should there be a guideline describing when/whether a prelude is good to have?
Sorry if this is not something that is considered "API" enough for the API guidelines.
Context: assert-rs/assert_cli#75 (comment) made me look up what the API guidelines say, and I couldn't find anything on the topic.
Beta Was this translation helpful? Give feedback.
All reactions