eyre-rs / color-eyre

Custom hooks for colorful human oriented error reports via panics and the eyre crate
Other
958 stars 57 forks source link

Ergonomics: Full re-exports from `eyre`; export `color_eyre::eyre!` macro, rather than `eyre` crate #145

Open LeoniePhiline opened 9 months ago

LeoniePhiline commented 9 months ago

I commonly use color_eyre and its re-exports from eyre.

However, not all commonly used symbols are re-exported. This results in nested imports like:

use color_eyre::{
    eyre::{bail, eyre, WrapErr},
    Report, Result,
};

The ambiguity between color_eyre::eyre (the crate re-export) and color_eyre::eyre::eyre (the macro) is also a pain point in my daily work.

(Rust analyzer unfortunately makes this worse by onlym despite the ! postfix, offering an auto-import of color_eyre::eyre instead of the correct color_eyre::eyre::eyre when eyre! is not in scope.)

From an ergonomics standpoint, I would wish for the full eyre feature-set (including e.g. WrapErr and OptionExt) to be re-exported from color_eyre:

use color_eyre::{bail, eyre, OptionExt, Report, Result, WrapErr};

In the above hypothetical use statement, the eyre imports the eyre! macro, not the eyre crate.

This is a breaking change.

LeoniePhiline commented 9 months ago

Note: anyhow-compat issues discussed at https://github.com/eyre-rs/eyre/issues/131 also apply to color_eyre re-exports.

LeoniePhiline commented 8 months ago

Status: Waiting on https://github.com/eyre-rs/eyre/pull/138 to be able to re-export anyhow compatibility layer.

Thus, this should also replace https://github.com/eyre-rs/color-eyre/pull/142.