up vote 387 down vote accepted I'd do it with cherry-pick -n (--no-commit) which lets you inspect (and modify) the result before committing:
git cherry-pick -n
//https://github.com/apple/swift-evolution/blob/master/proposals/0176-enforce-exclusive-access-to-memory.md | |
func modifying<T>(_ value: inout T, _ function: (inout T) -> ()) { | |
function(&value) | |
} | |
modifying(&object.pair) { pair in swap(&pair.x, &pair.y) } |
func baseToDecimal(_ base: Int, notation : [Int]) -> Int { | |
return notation.reversed().enumerated().filter { $0.element == 1 }.reduce(into: 0) { | |
let powR = Int(pow(Float(base), Float($1.offset))) | |
$0 += powR | |
} | |
} | |
func decimal(_ d : Int, toBase base: Int) -> [Int] { | |
var res = [Int]() |
extension FloatingPoint { | |
var isInt: Bool { | |
#if swift(>=4.0) | |
return self.truncatingRemainder(dividingBy: 1) == 0 | |
#else | |
return self % 1 == 0 | |
#endif | |
} | |
} |
for (a, b) in zip(A.enumerated(), B.enumerated()) { | |
print("a[\(a.offset)]: \(a.element)") | |
print("b[\(b.offset)]: \(b.element)") | |
} |
public struct Queue<T> : CustomStringConvertible where T : CustomStringConvertible { | |
fileprivate var array = [T]() | |
public var description: String { | |
var desc: String = "" | |
desc = array.reduce(into: desc) { | |
$0 += $1.description + "\n" | |
} | |
return desc | |
} |
extension String { | |
extension String { | |
func toArray() -> [Character] { | |
return Array(characters) | |
} | |
#if swift(>=4) | |
#else | |
var count: Int { |
let sessionConfiguration: URLSessionConfiguration = .default | |
let proxyConfiguration: [AnyHashable : Any] = [ | |
kCFNetworkProxiesHTTPEnable as AnyHashable: true, | |
kCFNetworkProxiesHTTPPort as AnyHashable: [Place-proxy's-port-number-here], | |
kCFNetworkProxiesHTTPProxy as AnyHashable: "Place-your-proxy-address-here" | |
] | |
sessionConfiguration.connectionProxyDictionary = proxyConfiguration |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
let k = DispatchSpecificKey<String>() | |
DispatchQueue.main.setSpecific(key: k, value: "MainQ") | |
public struct TextSize { | |
fileprivate struct CacheEntry: Hashable { | |
let text: String | |
let font: UIFont | |
let width: CGFloat | |
let insets: UIEdgeInsets | |
fileprivate var hashValue: Int { | |
return text.hashValue ^ Int(width) ^ Int(insets.top) ^ Int(insets.left) ^ Int(insets.bottom) ^ Int(insets.right) |