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
protocol Buildable { | |
init(dict: [AnyKeyPath: Any]) throws | |
} | |
struct BuilderError : Error { | |
let reason: String | |
} | |
struct SomeBuildable : Buildable { | |
let field1: String |
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 Network | |
let host: NWEndpoint.Host = .init("httpbin.org") | |
let port: NWEndpoint.Port = .https | |
let tlsConfig: NWProtocolTLS.Options = .init() | |
let parameters: NWParameters = .init(tls: tlsConfig) | |
let connection: NWConnection = .init(host: host, port: port, using: parameters) | |
connection.stateUpdateHandler = { state in | |
print("State Update: \(state)") | |
} |
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
#if os(Linux) | |
import Glibc | |
#else | |
import Darwin | |
#endif | |
public final class Future<Value> { | |
public typealias Handler = (Value) -> Void | |
public typealias Executor = (@escaping () -> Void) -> Void | |
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
// from: https://github.com/raywenderlich/swift-algorithm-club | |
public struct Heap<T> { | |
/** The array that stores the heap's nodes. */ | |
var nodes = [T]() | |
/** | |
* Determines how to compare two nodes in the heap. | |
* Use '>' for a max-heap or '<' for a min-heap, |
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 UIKit | |
// MARK: Corner rounding | |
public enum CornerRoundings { | |
case none | |
case all(CGFloat) | |
case topLeft(CGFloat) |
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
public protocol FluidView: UIView { | |
var id: UUID { get } | |
} | |
public protocol FluidViewLayoutModel { | |
var id: UUID { get } | |
var prefferedSize: CGSize? { get } | |
var prefferedInsets: UIEdgeInsets? { get } | |
var minimumSize: CGSize? { get } | |
var maximumSize: CGSize? { get } | |
func prepareView() -> FluidView |
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
//////////////////////////////////////////////////////// | |
//// From futura: https://github.com/miquido/futura //// | |
//////////////////////////////////////////////////////// | |
import Darwin | |
import libkern | |
public enum Mutex { | |
public typealias Pointer = UnsafeMutablePointer<pthread_mutex_t> |
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 protocol Executor { | |
func execute(_ task: @escaping () -> Void) | |
} | |
extension DispatchQueue: Executor { | |
@inlinable public func execute(_ task: @escaping () -> Void) { | |
async(execute: task) |
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 | |
import CoreData | |
// TODO: FIXME: minimal, naive implementation | |
internal final class EntityDecoder<EntityType: StorageEntity>: Decoder { | |
private let managed: NSManagedObject | |
public var codingPath: [CodingKey] = [] | |
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 extension Data { | |
func parse<T>(with parser: Parser<T>) -> T? { | |
self.withUnsafeBytes { (bufferPointer) -> T? in | |
var slice: Slice<Array<Byte>> = .init(bufferPointer) | |
return parser.parse(&slice) | |
} | |
} | |
} |
OlderNewer