From: Ian Jackson Date: Mon, 8 Mar 2021 20:51:35 +0000 (+0000) Subject: extension traits: Use extend::ext X-Git-Tag: otter-0.4.0~209 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2169660bb7f9ee8db7bb06700e3201d8adba7183;p=otter.git extension traits: Use extend::ext Signed-off-by: Ian Jackson --- diff --git a/wdriver.rs b/wdriver.rs index 5ca93d2b..4a334a2a 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -554,20 +554,18 @@ impl IntoInWindow for Pos { } } -pub trait ActionChainExt: Sized { +#[ext(pub, name=ActionChainExt, supertraits=Sized)] +impl<'a> t4::action_chain::ActionChain<'a> { + #[throws(AE)] fn move_w<'g, P: Debug + Copy + IntoInWindow> - (self, w: &'g WindowGuard, pos: P) -> Result; - - fn move_pos<'g, - E, - P: TryInto> - (self, pos: P) -> Result - where Result: anyhow::Context; - - fn move_pc<'g>(self, w: &'g WindowGuard, pc: &str) -> Result; -} + (self, w: &'g WindowGuard, pos: P) -> Self + { + let pos: WebPos = pos.w_into(w) + .with_context(|| format!("{:?}", pos)) + .context("find coordinate")?; + self.move_pos(pos)? + } -impl<'a> ActionChainExt for t4::action_chain::ActionChain<'a> { #[throws(AE)] fn move_pos<'g, E, @@ -580,16 +578,6 @@ impl<'a> ActionChainExt for t4::action_chain::ActionChain<'a> { self.move_to(px,py) } - #[throws(AE)] - fn move_w<'g, P: Debug + Copy + IntoInWindow> - (self, w: &'g WindowGuard, pos: P) -> Self - { - let pos: WebPos = pos.w_into(w) - .with_context(|| format!("{:?}", pos)) - .context("find coordinate")?; - self.move_pos(pos)? - } - #[throws(AE)] fn move_pc<'g>(self, w: &'g WindowGuard, pc: &str) -> Self { (||{