import Foundation
struct Parser<Input, Output> {
let run: (inout Input) -> Result<Output, Error>
}
extension Parser {
func runOn(_ input: Input) -> (match: Result<Output, Error>, rest: Input) {
var input = input
let match = self.run(&input)
return (match, input)
}
static func always(_ output: Output) -> Self {
Self { _ in .success(output) }
}
}
extension Parser where Output == String {
func asURL() -> Parser<Input, URL> {
.always(URL(string: "http://example.com")!)
}
}
enum Foo {
static let urlParser = Parser<String, URL> { input in
let parser = Parser<String, String>.always(input).asURL()
return parser.runOn(input).match
}
}
I get this warning when running SwiftFormat:
$ swiftformat --lint --verbose .
Running SwiftFormat...
(lint mode - no files will be changed.)
Reading config file at /Users/juri/Projects/SwiftFormat-unused-broken/.swiftformat
Linting /Users/juri/Projects/SwiftFormat-unused-broken/Example.swift
/Users/juri/Projects/SwiftFormat-unused-broken/Example.swift:26:1: warning: (unusedArguments) Mark unused function arguments with _.
-- rules applied: unusedArguments
SwiftFormat completed in 0.16s.
Source input did not pass lint check.
1/1 files require formatting.
I noticed this with 0.48.12, and I guess I was upgrading from 0.48.11, but I don't think Homebrew can confirm that for me.
I'm getting too eager triggering of unusedArguments. I'm using this config (which could use a bit of updating…):
And this minimized Swift file:
I get this warning when running SwiftFormat:
The argument is not unused, though.