From 77e0fc20d9b781299e07a15ed5ed3ca0599640ce Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 26 Feb 2021 13:00:56 +0000 Subject: [PATCH] utils: Loop: Provide and use Loop::ok Signed-off-by: Ian Jackson --- apitest/at-otter.rs | 2 +- src/utils.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index d5ce0ac2..a718c9db 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -144,7 +144,7 @@ impl Session { let puse = puse.value().as_element().ok_or(Loop::Continue)?; let attr = puse.attr("data-info").ok_or(Loop::Break)?; let info = serde_json::from_str(attr).unwrap(); - Ok::<_,Loop>(PieceInfo { id: (), info }) + Loop::ok(PieceInfo { id: (), info }) }) .collect() } diff --git a/src/utils.rs b/src/utils.rs index 66cfcf36..bd79992d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -302,6 +302,9 @@ pub enum Loop { impl From for Loop { fn from(e: E) -> Loop { Loop::Error(e) } } +impl Loop { + pub fn ok(t: T) -> Result> { Ok(t) } +} pub trait IteratorExt: Iterator where F: FnMut(Self::Item) -> Result>, -- 2.30.2