2 ms·
Author of `wherr` here again. Your approach is indeed elegant, and leveraging `#[track_caller]` is quite idiomatic. I also see the value in opting out of macro
by JoelJacobson 3y ago
Author of `wherr` here again.
Your approach is indeed elegant, and leveraging `#[track_caller]` is quite idiomatic. I also see the value in opting out of macros when possible.
However, I'm pondering the error matching aspect. Using your `MyErrorInner` design, one might want to downcast and match on specific error types:
if let Some(specific_err) = err.downcast_ref::<SpecificErrorType>() {
match specific_err {
SpecificErrorType::Variant => { /* ... */ },
// ... other matches
}
}
But this raises a question: Given that `MyErrorInner` holds a concrete `E` (which is, at runtime, a specific error type) and the public API exposes a boxed trait object, how would we effectively match against inner error types without resorting to static lifetimes?
In your design, while `location` is static, the concrete error type `E` is hidden away. Exposing it, especially without requiring static lifetimes, could be a challenge. Your thoughts?
Always a pleasure to dive into these Rust intricacies. Thanks for taking the time to contribute to this discussion!