-
|
Hi! First of all, let me say that I am very intrigued!
However, knowing the deep hierarchies that What happens if two errors use the same variant name but store different data. Or worse, have the same and the same data, but different display implementations and different semantics? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Agreed definitively a motivation that led me to create this crate.
If two errors use the same variant name but store different data error_set::error_set! {
Error1 = {
Variant(std::io::Error),
};
Error2 = {
Variant(std::fmt::Error),
};
Error3 = Error1 || Error2;
// Equal to the above
// Error3 = {
// Variant(std::io::Error),
// };
}If this is not what one wants, there are a few ways to currently approach this.
Error3 = {
Error1(Error1),
Error2(Error2),
};
Error3 = {
Variant1(std::io::Error),
Variant2(std::fmt::Error),
};impl From<Error1> for Error3 {
fn from(e: Error1) -> Self {
match e {
Error1::Variant(err) => Error3::Variant1(err),
}
}
}
...
Display messages are not considered when determining what can be converted into the other. So in error_set::error_set! {
Error1 = {
#[display("Some unique message: {0}")]
Variant(std::io::Error),
};
Error2 = {
#[display("Another unique message: {0}")]
Variant(std::io::Error),
};
}
|
Beta Was this translation helpful? Give feedback.


Agreed definitively a motivation that led me to create this crate.
If two errors use the same variant name but store different data
||only includes the first one that occupies that space -||works like an "or" operation for the set space.