mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 19:02:18 +00:00
Add equality operator for RegexMatch and Regex
- Technically a breaking change, but I doubt anyone depends on a compile-time error for long ;)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[Package]
|
||||
name = "nre"
|
||||
author = "Flaviu Tamas"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
description = "Yet another PCRE library"
|
||||
license = "MIT"
|
||||
srcDir = "src"
|
||||
|
||||
12
src/nre.nim
12
src/nre.nim
@@ -172,6 +172,18 @@ proc toSeq*(pattern: Captures, default: string = nil): seq[string] =
|
||||
|
||||
proc `$`*(pattern: RegexMatch): string =
|
||||
return pattern.captures[-1]
|
||||
|
||||
proc `==`*(a, b: Regex): bool =
|
||||
# name-to-number table is generated at init time, doesn't need to be checked
|
||||
return a.pattern == b.pattern and
|
||||
a.pcreObj == b.pcreObj and
|
||||
a.pcreExtra == b.pcreExtra
|
||||
|
||||
proc `==`*(a, b: RegexMatch): bool =
|
||||
# don't need to compare matchbounds, if pattern and str equal, everything
|
||||
# else will equal (unless callbacks, maybe? TODO)
|
||||
return a.pattern == b.pattern and
|
||||
a.str == b.str
|
||||
# }}}
|
||||
|
||||
# Creation & Destruction {{{
|
||||
|
||||
Reference in New Issue
Block a user