[Heap] Clean up description

- Don’t print the type name
- Include some information identifying the heap instance
This commit is contained in:
Karoy Lorentey committed 2024-02-02 16:20:21 -08:00
1 parent 37e66d0e49
commit 3c99c84286
2 files changed
+27 -6

No files matched your search

+11 -1
View File
@@ -12,7 +12,17 @@
extension Heap: CustomStringConvertible {
/// A textual representation of this instance.
public var description: String {
"Heap<\(Element.self)>(count: \(count))"
"<\(count) item\(count == 1 ? "" : "s") @\(_idString)>"
}
internal var _idString: String {
// "<32 items @0x2787abcf>"
_storage.withUnsafeBytes {
guard let p = $0.baseAddress else {
return "nil"
}
return String(UInt(bitPattern: p), radix: 16)
}
}
}