Full generation, file type cleanup
This commit is contained in:
@ -6,4 +6,8 @@ extension Array {
|
||||
Array(self[$0..<Swift.min($0 + size, count)])
|
||||
}
|
||||
}
|
||||
|
||||
var nonEmpty: Self? {
|
||||
isEmpty ? nil : self
|
||||
}
|
||||
}
|
||||
|
11
CHDataManagement/Extensions/ConvertThrowing.swift
Normal file
11
CHDataManagement/Extensions/ConvertThrowing.swift
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
prefix operator ~>
|
||||
|
||||
prefix func ~> (operation: () throws -> Void) -> Bool {
|
||||
do {
|
||||
try operation()
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
@ -27,3 +27,20 @@ extension Collection {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
extension Collection where Element: Collection, Element.Element: Hashable {
|
||||
|
||||
func union() -> Set<Element.Element> {
|
||||
reduce(into: []) { $0.formUnion($1) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension RangeReplaceableCollection where Element: Comparable {
|
||||
|
||||
|
||||
mutating func insertSorted(_ element: Element) {
|
||||
let index = firstIndex(where: { $0 > element }) ?? endIndex
|
||||
insert(element, at: index)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user