Skip to content

Instantly share code, notes, and snippets.

protocol Atomic {
var value: Int { get }
func increment()
}
class SwiftAtomic: Atomic {
private let counter = ManagedAtomic<Int>(0)
var value: Int {
enum Result<T> {
case Success(T)
case Failure(ErrorType?)
init() {
self = .Failure(nil)
}
init(_ f: () throws->T) {
do {
protocol Copyable {
associatedtype V
func copy() -> V
func setup(v: V) -> V
}
class One: Copyable {
typealias V = One
var name: String?
enum ControlFactoryError: ErrorType {
case TypeNotFound
}
protocol ControlFactory {
func create<T>(t: T.Type) throws -> UIView
}
class RealControlFactory: ControlFactory {
typealias FactoryItem = ()->(UIView)