Files
makata/Sources/interaction/protocol/protocol-withable.swift
2023-02-03 15:56:38 +08:00

23 lines
414 B
Swift

// protocol-withable.swift
//
// Code Copyright Buslo Collective
// Created 2/3/23
import Foundation
public protocol Withable {}
public extension Withable {
func with(_ closure: (Self) -> Void) -> Self {
closure(self)
return self
}
func with<Value>(path: KeyPath<Self, Value>, _ closure: (Value) -> Void) -> Self {
closure(self[keyPath: path])
return self
}
}