From 6b04d0395ab1d6d8efa7d287c73da2c7230800c9 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 22 Aug 2023 21:01:08 +0200 Subject: [PATCH] allow tuples and procs in 'toTask' + minor things (#22530) --- lib/pure/strscans.nim | 4 ++-- lib/std/tasks.nim | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim index 775c4244ac..0b23abc28b 100644 --- a/lib/pure/strscans.nim +++ b/lib/pure/strscans.nim @@ -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 @@ -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)` diff --git a/lib/std/tasks.nim b/lib/std/tasks.nim index 6a4b2bb6d8..9eb7c97c4e 100644 --- a/lib/std/tasks.nim +++ b/lib/std/tasks.nim @@ -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])