Skip to content

Commit 689f794

Browse files
committed
chore: Add withFilter
x
1 parent d1003d4 commit 689f794

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

fastparse/src-2/fastparse/package.scala

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ package object fastparse extends fastparse.SharedPackageDefs {
102102
def filter(f: T => Boolean)
103103
(implicit ctx: P[Any]): P[T] = macro MacroImpls.filterMacro[T]
104104

105+
/**
106+
* Used by for-comprehensions.
107+
*/
108+
def withFilter(f: T => Boolean)
109+
(implicit ctx: P[Any]): P[T] = macro MacroImpls.filterMacro[T]
110+
105111
/**
106112
* Transforms the result of this parser using the given partial function,
107113
* failing the parse if the partial function is not defined on the result

fastparse/src-3/fastparse/package.scala

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ package object fastparse extends fastparse.SharedPackageDefs {
3838
inline def filter(f: T => Boolean)(using ctx: P[Any]): P[T] =
3939
MacroInlineImpls.filterInline[T](parse0)(f)(ctx)
4040

41+
/**
42+
* Used by for-comprehensions.
43+
*/
44+
inline def withFilter(f: T => Boolean)(using ctx: P[Any]): P[T] = MacroInlineImpls.filterInline[T](parse0)(f)(ctx)
45+
4146
/** Either-or operator: tries to parse the left-hand-side, and if that
4247
* fails it backtracks and tries to pass the right-hand-side. Can be
4348
* chained more than once to parse larger numbers of alternatives.

0 commit comments

Comments
 (0)