Skip to content

Commit

Permalink
More expressibility by literals.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene committed Sep 17, 2021
1 parent 3d9bbbb commit f08206b
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Sources/Endpoints/Parameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,53 @@ where T: ExpressibleByStringLiteral {
}
}

extension HTTP.Parameter: ExpressibleByIntegerLiteral where T: ExpressibleByIntegerLiteral {

public init(integerLiteral value: T.IntegerLiteralType) {
self.init(value: T(integerLiteral: value))
}
}

extension HTTP.Parameter: ExpressibleByFloatLiteral where T: ExpressibleByFloatLiteral {

public init(floatLiteral value: T.FloatLiteralType) {
self.init(value: T(floatLiteral: value))
}
}

extension HTTP.Parameter: ExpressibleByBooleanLiteral where T: ExpressibleByBooleanLiteral {

public init(booleanLiteral value: T.BooleanLiteralType) {
self.init(value: T(booleanLiteral: value))
}
}

extension HTTP.Parameter: ExpressibleByNilLiteral where T: ExpressibleByNilLiteral {

public init(nilLiteral: ()) {
self.init(value: T(nilLiteral: nilLiteral))
}
}

extension HTTP.Parameter: ExpressibleByArrayLiteral where T: ExpressibleByArrayLiteral {

public typealias ArrayLiteralElement = T.ArrayLiteralElement

public init(arrayLiteral elements: T.ArrayLiteralElement...) {
self.init(value: elements as! T) // swiftlint:disable:this force_cast
}
}

extension HTTP.Parameter: ExpressibleByDictionaryLiteral where T: ExpressibleByDictionaryLiteral {

public typealias Key = T.Key
public typealias Value = T.Value

public init(dictionaryLiteral elements: (T.Key, T.Value)...) {
self.init(value: elements as! T) // swiftlint:disable:this force_cast
}
}


internal protocol AnyParameterValue {
var name: String { get }
Expand Down

0 comments on commit f08206b

Please sign in to comment.