From e93f9ca3ef919c7cb145476413ef83ba77253d6c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 8 Mar 2021 20:10:24 +0000 Subject: [PATCH] extension traits: Use extend::ext Signed-off-by: Ian Jackson --- apitest/at-otter.rs | 13 +++++-------- src/imports.rs | 1 + src/prelude.rs | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index f02c2146..ea98584b 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -35,8 +35,11 @@ mod scraper_ext { use scraper::*; use scraper::html::{*, Html}; - pub trait HtmlExt { - fn select<'a,'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b>; + #[ext(pub)] + impl Html { + fn select<'a,'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b> { + self.select(selector) + } #[throws(as Option)] fn element(&self, sel: S) -> ElementRef @@ -59,12 +62,6 @@ mod scraper_ext { } } - impl HtmlExt for Html { - fn select<'a,'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b> { - self.select(selector) - } - } - #[throws(AE)] pub fn parse_html(resp: reqwest::blocking::Response) -> Html { assert_eq!(resp.status(), 200); diff --git a/src/imports.rs b/src/imports.rs index cbe0c967..797824db 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -12,6 +12,7 @@ pub use chrono_tz; pub use delegate; pub use either; pub use env_logger; +pub use extend; pub use failure; pub use flexi_logger; pub use fs2; diff --git a/src/prelude.rs b/src/prelude.rs index 53c054d4..ed86ff6f 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -58,6 +58,7 @@ pub use downcast_rs::{impl_downcast, Downcast}; pub use either::{Either, Left, Right}; pub use enum_dispatch::enum_dispatch; pub use enum_map::{Enum, EnumMap}; +pub use extend::ext; pub use fehler::{throw, throws}; pub use flexi_logger::LogSpecification; pub use fs2::FileExt; -- 2.30.2