Skip to content

Commit 5b9aa2f

Browse files
author
Rob Rix
committed
Box is Printable.
1 parent 7740504 commit 5b9aa2f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Box/Box.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// Wraps a type `T` in a reference type.
44
///
55
/// Typically this is used to work around limitations of value types (for example, the lack of codegen for recursive value types and type-parameterized enums with >1 case). It is also useful for sharing a single (presumably large) value without copying it.
6-
public final class Box<T>: BoxType {
6+
public final class Box<T>: BoxType, Printable {
77
/// Initializes a `Box` with the given value.
88
public init(_ value: T) {
99
self.value = value
@@ -16,4 +16,11 @@ public final class Box<T>: BoxType {
1616
public func map<U>(f: T -> U) -> Box<U> {
1717
return Box<U>(f(value))
1818
}
19+
20+
21+
// MARK: Printable
22+
23+
public var description: String {
24+
return toString(value)
25+
}
1926
}

0 commit comments

Comments
 (0)