1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Memo can print itself.

This commit is contained in:
Rob Rix 2015-09-25 11:57:28 -04:00
parent b25095372a
commit ece5c942d5

View File

@ -1,4 +1,4 @@
public struct Memo<A> {
public struct Memo<A>: CustomDebugStringConvertible, CustomStringConvertible {
public init(unevaluted: () -> A) {
self.init(.Unevaluated(unevaluted))
}
@ -25,6 +25,15 @@ public struct Memo<A> {
public func flatMap<B>(transform: A -> Memo<B>) -> Memo<B> {
return Memo<B> { transform(self.value).value }
}
public var description: String {
return String(value)
}
public var debugDescription: String {
return String(reflecting: value)
}
}
private final class MutableBox<A> {