Instance Method
decode(column:inferringAs:)
This method exists to enable the compiler to perform type inference on the generic parameter
D of decode(column:as:). Protocols can not provide default arguments to methods, which is required for inference to work with generic type parameters. It is not expected that user code will invoke this method directly; rather it will be selected by the compiler automatically, as in this example:func decode<D>(column: String, inferringAs: D.Type = D.self) throws -> D where D : Decodable
Discussion
let row = getAnSQLRowFromSomewhere()
let id: Int = try row.decode(column: "id") // `D` is inferred to be `Int`
let name = try row.decode(column: "name") // Error: No context to infer the type from
struct Item { var property: Bool }
let item = Item(property: try row.decode(column: "property")) // `D` inferred as `Bool`
let meti = Item(property: try row.decode(column: "property", as: Bool?.self)) // Error: Can't assign Bool? to Bool