This file contains hidden or 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 JSONValueConvertible { | |
| var jsonValue: JSONValue { get } | |
| } | |
| protocol JSONValue: JSONValueConvertible { } | |
| extension JSONValue { | |
| var jsonValue: JSONValue { | |
| return self |
This file contains hidden or 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 BidirectionalCollection { | |
| func makeBidirectionalIterator() -> BidirectionalIterator<Self, Index> { | |
| return BidirectionalIterator<Self, Index>(collection: self) | |
| } | |
| } | |
| let a = [1, 2, 3, 4] |
This file contains hidden or 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 APIError: NetworkError { | |
| let json: JSON | |
| let apiCode: Int? | |
| let message: String? | |
| let httpResponse: HTTPURLResponse |
This file contains hidden or 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 TreeNode<Element> { | |
| var element: Element | |
| var children: [TreeNode<Element>] | |
| } | |
| class TreeNodeIterator<Element>: IteratorProtocol { | |
| var node: TreeNode<Element> | |
| var index = -1 | |
| var currentIterator: TreeNodeIterator<Element>? | |
This file contains hidden or 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 | |
| protocol StoryboardInitializable { | |
| static var storyboardName: String { get } | |
| static var storyboardIdentifier: String { get } | |
| static func makeFromStoryboard() -> Self | |
| } | |
| extension StoryboardInitializable { |
This file contains hidden or 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 | |
| protocol JSONInitializable { | |
| init?(data: Data) | |
| } | |
| protocol Request { | |
| associatedtype OutputType: JSONInitializable |
This file contains hidden or 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 Sequence { | |
| func uniqueElements(by elementsEqual: (Element, Element) -> Bool) -> [Element] { | |
| var result: [Element] = [] | |
| for element in self { | |
| if !result.contains(where: { resultElement in elementsEqual(element, resultElement) }) { | |
| result.append(element) | |
| } | |
| } | |
| return result | |
| } |
This file contains hidden or 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 HTTP | |
| import Vapor | |
| public protocol SideEffect { | |
| func perform() throws | |
| } | |
| public protocol Command: ResponseRepresentable { | |
This file contains hidden or 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 struct NilError: Error, CustomStringConvertible { | |
| let file: String | |
| let line: Int | |
| public init(file: String = #file, line: Int = #line) { | |
| self.file = file | |
| self.line = line | |
| } |
This file contains hidden or 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/Foundation.h> | |
| @interface Unit : NSObject | |
| @end | |
| typedef void (^SuccessBlock)(id _Nonnull object); | |
| typedef id _Nullable (^ _Nonnull ThenBlock)(id _Nonnull object); | |
| typedef void (^FailureBlock)(NSError * _Nonnull error); |