Skip to content

Commit

Permalink
lower restriction on End parser from Collection to Sequence (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
JaapWijnen authored Sep 19, 2022
1 parent bc92e84 commit f2bc528
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/Parsing/ParserPrinters/End.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@
///
/// > Note: This parser is automatically inserted when you invoke the non-incremental
/// > ``Parser/parse(_:)-6h1d0`` and ``Parser/parse(_:)-2wzcq`` methods.
public struct End<Input: Collection>: ParserPrinter {
public struct End<Input: Sequence>: ParserPrinter {
@inlinable
public init() {}

@inlinable
public func parse(_ input: inout Input) throws {
guard input.isEmpty else {
var iterator = input.makeIterator()
guard iterator.next() == nil else {
throw ParsingError.expectedInput("end of input", at: input)
}
}

@inlinable
public func print(_ output: (), into input: inout Input) throws {
guard input.isEmpty else {
var iterator = input.makeIterator()
guard iterator.next() == nil else {
let description = describe(input).map { "\n\n\($0.debugDescription)" } ?? ""
throw PrintingError.failed(
summary: """
Expand Down

0 comments on commit f2bc528

Please sign in to comment.