summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README.asciidoc2
-rw-r--r--src/nre.nim10
-rw-r--r--test/captures.nim8
3 files changed, 10 insertions, 10 deletions
diff --git a/README.asciidoc b/README.asciidoc
index 2fcc05ded..424a37a9f 100644
--- a/README.asciidoc
+++ b/README.asciidoc
@@ -101,7 +101,7 @@ is inclusive.
  - `"abc".match(re"abc").captureBounds[-1] == 0..3`
 `match: string` :: the full text of the match.
 `matchBounds: Slice[int]` :: the bounds of the match, as in `captureBounds[]`
-`(captureBounds|captures).asTable` :: returns a table with each named capture
+`(captureBounds|captures).toTable` :: returns a table with each named capture
 as a key.
 `(captureBounds|capture).toSeq` :: returns all the captures by their number.
 
diff --git a/src/nre.nim b/src/nre.nim
index 6ba5f560f..fbc143cd1 100644
--- a/src/nre.nim
+++ b/src/nre.nim
@@ -137,7 +137,7 @@ proc `[]`*(pattern: Captures, name: string): string =
   let pattern = RegexMatch(pattern)
   return pattern.captures[pattern.pattern.captureNameToId.fget(name)]
 
-template asTableImpl(cond: bool): stmt {.immediate, dirty.} =
+template toTableImpl(cond: bool): stmt {.immediate, dirty.} =
   for key in RegexMatch(pattern).pattern.captureNameId.keys:
     let nextVal = pattern[key]
     if cond:
@@ -145,16 +145,16 @@ template asTableImpl(cond: bool): stmt {.immediate, dirty.} =
     else:
       result[key] = nextVal
 
-proc asTable*(pattern: Captures, default: string = nil): Table[string, string] =
+proc toTable*(pattern: Captures, default: string = nil): Table[string, string] =
   ## Gets all the named captures and returns them
   result = initTable[string, string]()
-  asTableImpl(nextVal == nil)
+  toTableImpl(nextVal == nil)
 
-proc asTable*(pattern: CaptureBounds, default = None[Slice[int]]()):
+proc toTable*(pattern: CaptureBounds, default = None[Slice[int]]()):
     Table[string, Option[Slice[int]]] =
   ## Gets all the named captures and returns them
   result = initTable[string, Option[Slice[int]]]()
-  asTableImpl(nextVal.isNone)
+  toTableImpl(nextVal.isNone)
 
 template itemsImpl(cond: bool): stmt {.immediate, dirty.} =
   for i in 0 .. <RegexMatch(pattern).pattern.captureCount:
diff --git a/test/captures.nim b/test/captures.nim
index 15bdca7d9..bccbc0993 100644
--- a/test/captures.nim
+++ b/test/captures.nim
@@ -41,12 +41,12 @@ suite "captures":
 
   test "named capture table":
     let ex1 = "foo".find(initRegex("(?<foo>foo)(?<bar>bar)?"))
-    check(ex1.captures.asTable == {"foo" : "foo", "bar" : nil}.toTable())
-    check(ex1.captureBounds.asTable == {"foo" : Some(0..3), "bar" : None[Slice[int]]()}.toTable())
-    check(ex1.captures.asTable("") == {"foo" : "foo", "bar" : ""}.toTable())
+    check(ex1.captures.toTable == {"foo" : "foo", "bar" : nil}.toTable())
+    check(ex1.captureBounds.toTable == {"foo" : Some(0..3), "bar" : None[Slice[int]]()}.toTable())
+    check(ex1.captures.toTable("") == {"foo" : "foo", "bar" : ""}.toTable())
 
     let ex2 = "foobar".find(initRegex("(?<foo>foo)(?<bar>bar)?"))
-    check(ex2.captures.asTable == {"foo" : "foo", "bar" : "bar"}.toTable())
+    check(ex2.captures.toTable == {"foo" : "foo", "bar" : "bar"}.toTable())
 
   test "capture sequence":
     let ex1 = "foo".find(initRegex("(?<foo>foo)(?<bar>bar)?"))