Skip to content

Commit

Permalink
allow tuples and procs in 'toTask' + minor things (nim-lang#22530)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq authored Aug 22, 2023
1 parent a26ccb3 commit 6b04d03
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/pure/strscans.nim
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ The parsing is performed with the help of 3 helper templates that that can be
implemented for a custom type.
These templates need to be named ``atom`` and ``nxt``. ``atom`` should be
overloaded to handle both single characters and sets of character.
overloaded to handle both `char` and `set[char]`.
```nim
import std/streams
Expand Down Expand Up @@ -472,7 +472,7 @@ macro scanf*(input: string; pattern: static[string]; results: varargs[typed]): b

macro scanTuple*(input: untyped; pattern: static[string]; matcherTypes: varargs[untyped]): untyped {.since: (1, 5).}=
## Works identically as scanf, but instead of predeclaring variables it returns a tuple.
## Tuple is started with a bool which indicates if the scan was successful
## Tuple is started with a bool which indicates if the scan was successful
## followed by the requested data.
## If using a user defined matcher, provide the types in order they appear after pattern:
## `line.scanTuple("${yourMatcher()}", int)`
Expand Down
2 changes: 1 addition & 1 deletion lib/std/tasks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ macro toTask*(e: typed{nkCall | nkInfix | nkPrefix | nkPostfix | nkCommand | nkC
# passing by static parameters
# so we pass them directly instead of passing by scratchObj
callNode.add nnkExprEqExpr.newTree(formalParams[i][0], e[i])
of nnkSym, nnkPtrTy:
of nnkSym, nnkPtrTy, nnkProcTy, nnkTupleConstr:
addAllNode(param, e[i])
of nnkCharLit..nnkNilLit:
callNode.add nnkExprEqExpr.newTree(formalParams[i][0], e[i])
Expand Down

0 comments on commit 6b04d03

Please sign in to comment.