Note that anyhow
itself should be accessible without use
(as of Edition 2018), because this is a crate name. If you mean to import something within that crate for your entire project (use anyhow::Context;
), then no, there is no standard¹ way to have that.
Each module has its own scope for such symbols, which are imported via use
. The one exception is in the standard preludes, defined by the compiler itself. These are what enable you to use Copy
, Result
, and others without having to import them explicitly. However, this is naturally out of your control.
There is also a common pattern for some libraries to provide their own prelude: a module that re-exports symbols that are likely to be useful. anyhow
does not provide one at the time of writing.
See also:
¹Almost anything becomes possible with macros or another preprocessor, but it is hardly a good tradeoff for this case.