This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public struct WeakSet<Element>: Sequence, ExpressibleByArrayLiteral, CustomStringConvertible where Element: AnyObject { | |
private var storage = Set<Box>() | |
public init(_ members: [Element]) { | |
members.forEach { insert($0) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CGPath { | |
func apply(action: @escaping (CGPathElement)->()) { | |
var action = action | |
apply(info: &action) { | |
let action = $0!.bindMemory(to: ((CGPathElement)->()).self, capacity: 1).pointee | |
action($1.pointee) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct AnyEquatable: Equatable { | |
let base: Any | |
let isEqual: (_ other: AnyEquatable) -> Bool | |
init<T: Equatable>(_ base: T) { | |
self.base = base | |
self.isEqual = { base == $0.base as? T } | |
} | |
public static func ==(lhs: AnyEquatable, rhs: AnyEquatable) -> Bool { |
NewerOlder