[ad_1]
I’m attempting to create a variable of a generic perform kind:
import Basis
typealias Processor<T:Decodable> = (T.Sort, URL) -> Promise<T>
struct Service {
let processor: Processor
func getAPI1() -> Promise<TypedResponse1> {
let url = ...
return processor(TypedResponse1.self, url)
}
func getAPI2(params: [String]) -> Promise<TypedResponse2> {
let url = ...
return processor(TypedResponse2.self, url)
}
}
Compiling offers me an error:
Reference to generic kind 'Processor' requires arguments in <...>
Nonetheless, I do not wish to specialize the variable because it kinda beats the aim of getting it and might be tougher to check.
How can I accomplish this?
[ad_2]
