Skip to content

Commit be234e0

Browse files
committed
Merge development into main
2 parents 84ddaa5 + b473eea commit be234e0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Sources/ComposableRequest/Wrapper/Wrappable.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ import CoreGraphics
1212
#endif
1313

1414
/// A `protocol` allowing to `init` `Wrapper`s.
15-
public protocol Wrappable {
15+
public protocol Wrappable: CustomStringConvertible {
1616
/// Wrap `self` into a `Wrapper`.
1717
var wrapped: Wrapper { get }
1818
}
1919

20+
public extension Wrappable {
21+
/// The description.
22+
///
23+
/// - note: Override this for custom behavior.
24+
var description: String { wrapped.description }
25+
}
26+
2027
extension Bool: Wrappable {
2128
/// Wrap `self` into a `Wrapper`.
2229
public var wrapped: Wrapper { .init(booleanLiteral: self) }
@@ -47,6 +54,13 @@ extension NSNull: Wrappable {
4754
public var wrapped: Wrapper { .empty }
4855
}
4956

57+
extension Optional: CustomStringConvertible where Wrapped: Wrappable {
58+
/// The description.
59+
///
60+
/// - note: Override this for custom behavior.
61+
public var description: String { self?.description ?? "<empty>" }
62+
}
63+
5064
extension Optional: Wrappable where Wrapped: Wrappable {
5165
/// Wrap `self` into a `Wrapper`.
5266
public var wrapped: Wrapper { flatMap { $0.wrapped } ?? .empty }

0 commit comments

Comments
 (0)