From: Ian Jackson Date: Fri, 26 Feb 2021 13:00:56 +0000 (+0000) Subject: utils: Loop: Provide and use Loop::ok X-Git-Tag: otter-0.4.0~349 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=77e0fc20d9b781299e07a15ed5ed3ca0599640ce;p=otter.git utils: Loop: Provide and use Loop::ok Signed-off-by: Ian Jackson --- 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>,