Skip to content

const Regex compilation #1012

Answered by BurntSushi
sae3023 asked this question in Q&A
Discussion options

You must be logged in to vote

It is somewhat addressed here: #913

For the specific case of a const method, theoretically, one could implement a regex engine using Rust const, but certainly not the one in this crate. To a first approximation, in order for this crate to have a pub const fn new(pattern: &'static str) -> Regex, you would need to have most of the Rust language usable inside a const context. That is nowhere near the case today.

The issue I linked addresses the more general case of "compile time regex" and specifically, "a serialization format for a regex that enables cheap deserialization." Rust const is just one way of getting a compile time regex. There are other techniques, as that issue covers.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants