From: Ian Jackson Date: Sun, 4 Apr 2021 19:23:18 +0000 (+0100) Subject: apitest: Use #[ext] a bit more X-Git-Tag: otter-0.5.0~204 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=41d54cd3905e21b16536e9fe73c714d1b887292c;p=otter.git apitest: Use #[ext] a bit more Signed-off-by: Ian Jackson --- diff --git a/apitest/apitest.rs b/apitest/apitest.rs index 1da3d538..a8ecaef4 100644 --- a/apitest/apitest.rs +++ b/apitest/apitest.rs @@ -255,26 +255,17 @@ macro_rules! test { // -------------------- Extra anyhow result handling -------------------- -pub trait AlwaysContext { - fn always_context(self, msg: &'static str) -> anyhow::Result; -} - -impl AlwaysContext for Result -where Self: anyhow::Context, -{ - fn always_context(self, msg: &'static str) -> anyhow::Result { +#[ext(pub)] +impl Result { + fn always_context(self, msg: &'static str) -> anyhow::Result + where Self: anyhow::Context + { let x = self.context(msg); if x.is_ok() { info!("completed {}.", msg) }; x } -} - -pub trait JustWarn { - fn just_warn(self) -> Option; -} -impl JustWarn for Result { - fn just_warn(self) -> Option { + fn just_warn(self) -> Option where E: Display { match self { Ok(x) => Some(x), Err(e) => {