I have a function like:
protocol SQLValueConvertible {
static func value(statement: OpaquePointer, index: Int32) -> Any
}
extension String: SQLValueConvertible {
public static func value(statement: OpaquePointer, index: Int32) -> Any {
sqlite3_column_text(statement, index).map({ String(cString: $0) }) ?? ""
}
}
protocol SQLiteTable {
associatedtype StatementColumns
}
func query<Table: SQLiteTable, Value1: SQLValueConvertible, Value2: SQLValueConvertible>(table: Table) -> [Table.StatementColumns] where Table.StatementColumns == (Value1, Value2) { }
When I call this function
struct QueryTable: SQLiteTable {
typealias StatementColumns = (value1: String, value2: String)
}
query(table: QueryTable())
It gives me these errors:
Generic parameter 'Value1' could not be inferred
Generic parameter 'Value2' could not be inferred
Instance method 'query(table:)' requires the types 'QueryTable.StatementColumns' (aka '(value1: String, value2: String)') and '(Value1, Value2)' be equivalent
Is this a limitation of swift? Or am I using it wrong?