Skip to content

Commit

Permalink
Added parseOrNull
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel committed Dec 30, 2023
1 parent 5e8f1f8 commit 1b9106f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ fun interface Parser<in I, out O, out E> {
*/
fun parse(input: I): EitherNel<E, O>

/**
* Parses the given [input], returning a successful result, or null in the case of an error.
*/
fun parseOrNull(input: I): O? = parse(input).getOrNull()

/**
* Returns a new Parser<J> that wraps this parser, by using the supplied function [f]
* to convert a given [J] into an [I].
Expand Down

0 comments on commit 1b9106f

Please sign in to comment.