diff options
Diffstat (limited to 'third_party/rust/thiserror/src/aserror.rs')
-rw-r--r-- | third_party/rust/thiserror/src/aserror.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/third_party/rust/thiserror/src/aserror.rs b/third_party/rust/thiserror/src/aserror.rs new file mode 100644 index 0000000000..82902967cd --- /dev/null +++ b/third_party/rust/thiserror/src/aserror.rs @@ -0,0 +1,33 @@ +use std::error::Error; + +pub trait AsDynError { + fn as_dyn_error(&self) -> &(dyn Error + 'static); +} + +impl<T: Error + 'static> AsDynError for T { + #[inline] + fn as_dyn_error(&self) -> &(dyn Error + 'static) { + self + } +} + +impl AsDynError for dyn Error + 'static { + #[inline] + fn as_dyn_error(&self) -> &(dyn Error + 'static) { + self + } +} + +impl AsDynError for dyn Error + Send + 'static { + #[inline] + fn as_dyn_error(&self) -> &(dyn Error + 'static) { + self + } +} + +impl AsDynError for dyn Error + Send + Sync + 'static { + #[inline] + fn as_dyn_error(&self) -> &(dyn Error + 'static) { + self + } +} |