Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes fusion tests #104

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/fusion/matching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"]``
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/tmatching.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down