Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lower restriction on End parser from Collection to Sequence #250

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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