zkat / miette

Fancy extension for std::error::Error with pretty, detailed diagnostic printing.
https://docs.rs/miette
Apache License 2.0
1.97k stars 113 forks source link

Feature Request: Make miette! macro handle related errors #390

Open RobertasJ opened 1 month ago

RobertasJ commented 1 month ago

Problem Right now, to use related errors in the miette! macro, you have to create a custom struct with a #[related] field. This can be a bit cumbersome and adds extra boilerplate.

Solution It would be great if the related field in the miette! macro could accept any iterator, like a Vec or any type implementing IntoIterator.

zkat commented 1 month ago

this sounds nice. I'd take a PR for this as long as it's not semver-breaking.

RobertasJ commented 1 month ago

sure, from what i saw it was a pretty easy fix, if the macro works how i expect it to (which means i dont have to change it).

RobertasJ commented 1 month ago

It seems like the reason that these havent been implemented is because this would either require the dyn objects it holds to be clone or it would have to remove its clone derive, this includes over traits like partialeq and eq. as for the related errors part, it needs lifetimes which will also probably break some stuff.