From: Ian Jackson Date: Fri, 26 Feb 2021 00:58:17 +0000 (+0000) Subject: apitest: Break out HtmlExt::element() X-Git-Tag: otter-0.4.0~358 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d897bc317517104aab16dcc3cfdb16feec62c896;p=otter.git apitest: Break out HtmlExt::element() Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index bb09c6cb..c1ca5c94 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -35,13 +35,22 @@ mod scraper_ext { fn select<'a,'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b>; #[throws(as Option)] - fn e_attr(&self, sel: S, attr: &str) -> &str + fn element(&self, sel: S) -> ElementRef where S: TryInto, >::Error: Debug, { self .select(&sel.try_into().unwrap()) .next()? + } + + #[throws(as Option)] + fn e_attr(&self, sel: S, attr: &str) -> &str + where S: TryInto, + >::Error: Debug, + { + self + .element(sel).unwrap() .value().attr(attr)? } }