[swift-evolution] Feedback on SE-0166 and SE-0167

Itai Ferber iferber at apple.com
Sat May 27 14:27:09 CDT 2017


Excellent! Glad that ended up working out — looking forward to seeing 
this improve quality of life for GRDB users and others. :)

On 27 May 2017, at 3:40, Gwendal Roué wrote:

> > Le 27 mai 2017 à 11:59, David Hart <david at hartbit.com> a écrit :
>>
>> I didn’t know that was possible either! Really cool. Even better:
>>
>>  if let databaseValueType = T.self as? DatabaseValueConvertible.Type 
>> {
>>      let databaseValue: DatabaseValue = row.value(named: 
>> key.stringValue)
>>      return databaseValueType.fromDatabaseValue(databaseValue) as! T
>>  } else { … }
>
>
> Yes, that's even more clear like that :-)
>
> And for Encodable support, it works just great (not a single line of 
> boilerplate code):
>
>     private enum Color: String, DatabaseValueConvertible, Encodable {
>         case red, green, blue
>     }
>
>     private struct EncodableStruct : Persistable, Encodable {
>         static let databaseTableName = "myTable"
>         let name: String
>         let color: Color?
>     }
>
>     try dbQueue.inDatabase { db in
>         try EncodableStruct(name: "Arthur", color: .red).insert(db)
>     }
>
> Gwendal


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170527/5ce7e4b6/attachment.html>


More information about the swift-evolution mailing list