nitely / nim-regex

Pure Nim regex engine. Guarantees linear time matching
https://nitely.github.io/nim-regex/
MIT License
228 stars 21 forks source link

Have a way to know if regex object is initialized #39

Closed genotrance closed 5 years ago

genotrance commented 5 years ago

It is as simple as r.states.len != 0 but since states is a private field, there's no way to tell if a regex is initialized or not.

I'm initializing many regexes recursively and can go into an infinite loop if I don't have a way to check if an object is already initialized.

For now, I'm going to "states: @[]" in $r but it seems hacky.

nitely commented 5 years ago

I added r.isInitialized

https://github.com/nitely/nim-regex/commit/560cef536c78765b94754082c704678c4ebaae29

genotrance commented 5 years ago

Brilliant!