chiark / gitweb /
apitest: Use #[ext] a bit more
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Apr 2021 19:23:18 +0000 (20:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Apr 2021 22:12:28 +0000 (23:12 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/apitest.rs

index 1da3d5386d50d7dc1d0a79eac271ea627fb0c98f..a8ecaef495b0981581014bd7812685433b06e77c 100644 (file)
@@ -255,26 +255,17 @@ macro_rules! test {
 
 // -------------------- Extra anyhow result handling --------------------
 
-pub trait AlwaysContext<T,E> {
-  fn always_context(self, msg: &'static str) -> anyhow::Result<T>;
-}
-
-impl<T,E> AlwaysContext<T,E> for Result<T,E>
-where Self: anyhow::Context<T,E>,
-{
-  fn always_context(self, msg: &'static str) -> anyhow::Result<T> {
+#[ext(pub)]
+impl<T,E> Result<T,E> {
+  fn always_context(self, msg: &'static str) -> anyhow::Result<T>
+  where Self: anyhow::Context<T,E>
+  {
     let x = self.context(msg);
     if x.is_ok() { info!("completed {}.", msg) };
     x
   }
-}
-
-pub trait JustWarn<T> {
-  fn just_warn(self) -> Option<T>;
-}
 
-impl<T> JustWarn<T> for Result<T,AE> {
-  fn just_warn(self) -> Option<T> {
+  fn just_warn(self) -> Option<T> where E: Display {
     match self {
       Ok(x) => Some(x),
       Err(e) => {