IS
Size: a a a
IS
S
В
В
IS
enum O<T> { case none, some(T) }
protocol Addictable { static func +(l: Self, r: Self) -> Self }
extension O where T: Addictable {
static func +(_ a: Self, _ b: Self) -> Self where T: Addictable {
switch (a, b) {
case let (.some(aa), .some(bb)): return O<T>.some(aa + bb)
default: return .none
}
}
}
// magic is here
extension Int: Addictable { }
let v1 = O.some(123)
let v2 = O.some(234)
v1 + v2 // 357
IS
В
extension O where T: Addictable {
В
IS
В
В
В
IS
В
S
S
В
S
В