~=(_:_:)

public func ~=<T, U>(lhs: Parser<T, U>, rhs: T) -> Bool

~= allows the usage of Parsers in switch-case pattern matching statements.

example:

switch "a" {
    case L.char: print("it's a char \o/")
    case L.digit: print("it's a digit!")
    default: print("it's something unexpected :/")

NOTE: Be aware that this also checks if the rest is empty to ensure the whole input matches!

  • T

    Declaration

    Swift

    public func ~=<T, U>(lhs: Parser<T, U>, rhs: T) -> Bool