scraper
scraper copied to clipboard
Allow `Selector` to be const-creatable
Currently we cannot create const SELECTOR: Selector = ... object, due to Selector::parse not being const.
This in turn would require cssparser::Tokenizer::new() and cssparser::Tokenizer::with_first_line_number() to be const as well.
I think that this would be possible to do.
I am highly sceptical this will be possible soon as this would require things like selectors::parser::SelectorList::parse to be const.
Probably. I'm currently using once_cell::sync::Lazy to work around this limitation.
OnceCell is now part of the standard library: https://github.com/rust-lang/rfcs/pull/2788 I think this should be considered the solution to this issue, since we cannot make Selector const-creatable