The documentation for
Accessing a type's
descriptionproperty directly or using
CustomStringConvertibleas a generic constraint is discouraged.
But this is never elaborated upon. Why is it discouraged to write
Since this is also a requirement of
LosslessStringConvertible, it seems more straightforward to me that
aThing.description matches with
ThingType.init?(_ description: String) (i.e. I got a string directly from the object, so I expect the object also knows how to parse that String).
String(describing: aThing) seems too indirect for my liking. Is String doing anything other than returning the
description? I don't know. Neither does the object who expects to parse this string again.