Skip to content

Allow Selector to be const-creatable #141

Closed

Description

@conqp

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.

Activity

  1. adamreichold commented on Sep 2, 2023

    @adamreichold
    Member

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

  2. conqp commented on Sep 3, 2023

    @conqp
    Author

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

  3. cfvescovo commented on Feb 29, 2024

    @cfvescovo
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions