Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Selector to be const-creatable #141

Closed
conqp opened this issue Sep 2, 2023 · 3 comments
Closed

Allow Selector to be const-creatable #141

conqp opened this issue Sep 2, 2023 · 3 comments
Labels
C-enhancement Category: enhancement

Comments

@conqp
Copy link

conqp commented Sep 2, 2023

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.

@adamreichold
Copy link
Member

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

@conqp
Copy link
Author

conqp commented Sep 3, 2023

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

@teymour-aldridge teymour-aldridge added the C-enhancement Category: enhancement label Sep 8, 2023
@cfvescovo
Copy link
Member

OnceCell is now part of the standard library: rust-lang/rfcs#2788
I think this should be considered the solution to this issue, since we cannot make Selector const-creatable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancement
Projects
None yet
Development

No branches or pull requests

4 participants