feat: re-export everything from eyre - #282
Conversation
|
Discussion started here. |
4e8b6cb to
4eec6f8
Compare
| /// format!( | ||
| /// "This might have failed due to ... It has failed {} times", | ||
| /// 100 | ||
| /// ) | ||
| /// })?; |
There was a problem hiding this comment.
There are some unrelated changes like this in doc comments as I formatted the code with rustfmt's format_doc_in_comments option to fix ordering of use statements. If you don't mind I would like to keep them, but it's no issue to remove them or split them in a different PR.
color-eyre is just a thin wrapper around eyre and should behave the same. This includes the API. For this purpose all items that are publicly available in eyre should be available without another submodule from color-eyre.
4eec6f8 to
d76663b
Compare
|
Fantastic. The new imports as seen in the diff are the API I had always wished for. I would love to see this merged, but I would also like to see more discussion about a possible merge:
It may not be useful to keep I would like to recommend changing crate — (Follow up): Gated by The |
Does this prevent people from creating custom eyre handlers, without bringing in I'd like to keep the opportunity for other crates to develop their own custom eyre hook (I'm working on one myself) Currently on the main branch, that looks like this: ---
[dependencies]
eyre = "0.6"
color-eyre = "0.6"
---
use color_eyre::Result;
fn main() -> Result {
color_eyre::install();
Ok(())
}With a custom hook, not from ---
[dependencies]
eyre = "0.6"
fancy-panic = { version = "0.1", features = ["eyre"] }
---
use eyre::Result;
fn main() -> Result {
fancy_eyre::install();
Ok(())
}With your proposed changes, usage of the colored hook is simplified: ---
[dependencies]
eyre = "1.0"
---
use eyre::Result;
fn main() -> Result {
eyre::install();
Ok(())
}Let's assume that the Then to use an external handler, you have to disable the default feature, and you also have to enable features that are enabled by default: ---
[dependencies]
eyre = { version = "0.6", default-features = false, features = ["track-caller"] }
fancy-panic = { version = "0.1", features = ["eyre"] }
---
use eyre::Result;
fn main() -> Result {
fancy_eyre::install();
Ok(())
}Alternatively, if we keep the ---
[dependencies]
eyre-core = "1.0"
fancy-panic = { version = "0.1", features = ["eyre"] }
---
use eyre_core::Result;
fn main() -> Result {
fancy_eyre::install();
Ok(())
}Which I think is actually worse, because we want to consider use eyre::prelude::*;Instead of: use eyre_core::prelude::*;Using a different report handler shouldn't require renaming every module where This basically forces the user to do a crate rename: eyre = { package = "eyre-core", version = "1.0" }
fancy-panic = { version = "0.1", features = ["eyre"] }Which leaks implementation details as well (user shouldn't have to know about So the tradeoffs are:
My proposal is to do what you said, but put the ---
[dependencies]
eyre = { version = "1.0", features = ["color"] }
---
use eyre::Result;
fn main() -> Result {
eyre::install();
Ok(())
}Which makes using an external hook easier: ---
[dependencies]
eyre = "1.0"
fancy-panic = { version = "0.1", features = ["eyre"] }
---
use eyre::Result;
fn main() -> Result {
fancy_eyre::install();
Ok(())
}This seems like a fair compromise. However, it does make using the blessed color-eyre handler case harder to use, so if that's not a tradeoff you are willing to do, then I will understand. |
color-eyre is just a thin wrapper around eyre and should behave the same. This includes the API. For this purpose all items that are publicly available in eyre should be available without another submodule from color-eyre.