mirror of
https://github.com/tower-rs/tower.git
synced 2025-09-28 13:30:43 +00:00
ready-cache: Properly expose error source (#467)
The `ready_cache::error::Failed` type does not actually expose its inner error type via `Error::source`. This change fixes this and improves debug formatting. This change adds a new constraint, ensuring that keys impl Debug in order for the `error::Failed` type to impl Debug/Error.
This commit is contained in:
parent
ab7518ef13
commit
ad348d8ee5
@ -6,9 +6,12 @@ pub struct Failed<K>(pub K, pub crate::BoxError);
|
||||
|
||||
// === Failed ===
|
||||
|
||||
impl<K> std::fmt::Debug for Failed<K> {
|
||||
impl<K: std::fmt::Debug> std::fmt::Debug for Failed<K> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
std::fmt::Debug::fmt(&self.1, f)
|
||||
f.debug_tuple("Failed")
|
||||
.field(&self.0)
|
||||
.field(&self.1)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,8 +21,8 @@ impl<K> std::fmt::Display for Failed<K> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K> std::error::Error for Failed<K> {
|
||||
impl<K: std::fmt::Debug> std::error::Error for Failed<K> {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
self.1.source()
|
||||
Some(&*self.1)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user