Given the following programs:
struct MyType {}
extension MyType: CustomStringConvertible {
var description: String {
"description of MyType"
}
}
extension MyType: CustomDebugStringConvertible {
var debugDescription: String {
"debugDescription of MyType"
}
}
@main
struct Main {
static func main() async throws {
print([MyType()])
debugPrint([MyType()])
}
}
this prints
[debugDescription of MyType]
[debugDescription of MyType]
but I would expect that the first print
This seems to be on purpose from the code comments in _makeCollectionDescription: https://github.com/apple/swift/blob/86265881c3a8c0480f94ebeedd67aef607d4a1f1/stdlib/public/core/ArrayShared.swift#L119
However, this is very unexpected and also probably quite slow as it looks like debugPrint cannot be specialised.
This also affects ArraySlice, ContiguousArray, Dictionary and Set.
Given the following programs:
this prints
but I would expect that the first print
This seems to be on purpose from the code comments in _makeCollectionDescription: https://github.com/apple/swift/blob/86265881c3a8c0480f94ebeedd67aef607d4a1f1/stdlib/public/core/ArrayShared.swift#L119
However, this is very unexpected and also probably quite slow as it looks like debugPrint cannot be specialised.
This also affects ArraySlice, ContiguousArray, Dictionary and Set.