scraper icon indicating copy to clipboard operation
scraper copied to clipboard

Allow `Selector` to be const-creatable

Open conqp opened this issue 2 years ago • 2 comments

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.

conqp avatar Sep 02 '23 11:09 conqp

I am highly sceptical this will be possible soon as this would require things like selectors::parser::SelectorList::parse to be const.

adamreichold avatar Sep 02 '23 12:09 adamreichold

Probably. I'm currently using once_cell::sync::Lazy to work around this limitation.

conqp avatar Sep 03 '23 18:09 conqp

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

cfvescovo avatar Feb 29 '24 09:02 cfvescovo