causal-agent / scraper

HTML parsing and querying with CSS selectors
https://docs.rs/scraper
ISC License
1.79k stars 98 forks source link

feat: ToCss for Selector #153

Closed EdJoPaTo closed 8 months ago

EdJoPaTo commented 8 months ago

I would like to use ToCss for the Selector. Selector is basically a wrapper of the cssparser::SelectorList which implements this trait too.

SelectorList is containing exactly the content of Selector::selectors but with redeclaring it and requiring the explicit dependency on smallvec. Changing this removes smallvec as a direct dependency. This should even have the same memory footprint as Rust optimizes the wrapper struct away.

Using pub for the use ToCSS is probably debatable but I think its a good thing to easily allow to use to_css and to_css_string without specifying the cssparser dependency explicitly and rather use scraper::selector::ToCss instead.

cfvescovo commented 8 months ago

LGTM