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
internal protocol AnyParameter { | |
var name: String { get } | |
var optional: Bool { get } | |
var type: Any.Type { get } | |
} | |
public struct Parameter<Value>: AnyParameter { | |
public var name: String | |
public var optional: Bool | |
public var `default`: Value? |
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(macOS) || os(iOS) || os(tvOS) || os(watchOS) | |
import libkern // check on Linux | |
public enum AtomicFlag { | |
public typealias Pointer = UnsafeMutablePointer<atomic_flag> | |
@inline(__always) | |
public static func make() -> Pointer { | |
let pointer = Pointer.allocate(capacity: 1) |
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) | |
} | |
} | |
} |
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 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
//////////////////////////////////////////////////////// | |
//// 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
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
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
// 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
#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 | |
NewerOlder