From c1e0a47a187066de3fc9c3036f0eae4fda5c5972 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 22 Nov 2022 01:41:45 +0800 Subject: [PATCH 1/2] fixes fusion tests --- tests/tmatching.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/tmatching.nim b/tests/tmatching.nim index 5c89b9c..b1ce08a 100644 --- a/tests/tmatching.nim +++ b/tests/tmatching.nim @@ -904,6 +904,9 @@ suite "Matching": text*: string subn*: seq[HtmlNode] + proc `==`(x, y: HtmlNode): bool {.noSideEffect.} = + x.kind == y.kind and x.text == y.text and x.subn == y.subn + func add(n: var HtmlNode, s: HtmlNode) = n.subn.add s func len(n: HtmlNode): int = n.subn.len From 6f101e37ac119bbc01b9d5936e9889c07616773d Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 22 Nov 2022 10:46:45 +0800 Subject: [PATCH 2/2] fixes headings --- src/fusion/matching.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fusion/matching.rst b/src/fusion/matching.rst index c6b61b5..574b620 100644 --- a/src/fusion/matching.rst +++ b/src/fusion/matching.rst @@ -243,7 +243,7 @@ subpatterns or have trailing ``.._`` in pattern. ============= ============== ============== Use examples -~~~~~~~~~~~~ +############ - capture all elements in sequence: ``[all @elems]`` - get all elements until (not including "d"): ``[until @a is "d"]`` @@ -419,7 +419,7 @@ Predicates and infix operators ------------------------------ Infix operators -~~~~~~~~~~~~~~~ +############### By default object fields are either matched using recursive pattern, or compared for equality (when ``field: "some value"`` is used). It is also @@ -437,7 +437,7 @@ visible in the case branch. Custom predicates -~~~~~~~~~~~~~~~~~ +################# Matching expressions using custom predicates is also possible. If it is not necessary to capture matched element placeholder ``_.`` should be used as a