warpgate/warpgate-protocol-ssh/src/compat.rs
Eugene Pankov 4ccf2b0437
import
2022-04-10 22:58:58 +02:00

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))
}
}