Skip to content

Commit cc8f68c

Browse files
author
Rob Rix
committed
MutableBox is Printable.
1 parent 5b9aa2f commit cc8f68c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Box/MutableBox.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/// While this, like `Box<T>` could be used to work around limitations of value types, it is much more useful for sharing a single mutable value such that mutations are shared.
66
///
77
/// As with all mutable state, this should be used carefully, for example as an optimization, rather than a default design choice. Most of the time, `Box<T>` will suffice where any `BoxType` is needed.
8-
public final class MutableBox<T>: MutableBoxType {
8+
public final class MutableBox<T>: MutableBoxType, Printable {
99
/// Initializes a `MutableBox` with the given value.
1010
public init(_ value: T) {
1111
self.value = value
@@ -18,4 +18,10 @@ public final class MutableBox<T>: MutableBoxType {
1818
public func map<U>(f: T -> U) -> MutableBox<U> {
1919
return MutableBox<U>(f(value))
2020
}
21+
22+
// MARK: Printable
23+
24+
public var description: String {
25+
return toString(value)
26+
}
2127
}

0 commit comments

Comments
 (0)