mirror of
https://github.com/warp-tech/warpgate.git
synced 2025-02-23 23:16:27 +08:00
14 lines
349 B
Rust
14 lines
349 B
Rust
use std::fmt::Display;
|
|
|
|
pub trait ContextExt<T, C> {
|
|
fn context(self, context: C) -> anyhow::Result<T>;
|
|
}
|
|
|
|
impl<T, C> ContextExt<T, C> for Result<T, ()>
|
|
where
|
|
C: Display + Send + Sync + 'static,
|
|
{
|
|
fn context(self, context: C) -> anyhow::Result<T> {
|
|
self.map_err(|_| anyhow::anyhow!("unspecified error").context(context))
|
|
}
|
|
}
|