Occupiable.swift 656 B

12345678910111213141516171819202122
  1. import Foundation
  2. // Originally from here: https://github.com/artsy/eidolon/blob/f95c0a5bf1e90358320529529d6bf431ada04c3f/Kiosk/App/SwiftExtensions.swift#L23-L40
  3. // Credit to Artsy and @ashfurrow
  4. // Anything that can hold a value (strings, arrays, etc.)
  5. public protocol Occupiable {
  6. var isEmpty: Bool { get }
  7. var isNotEmpty: Bool { get }
  8. }
  9. public extension Occupiable {
  10. var isNotEmpty: Bool {
  11. return !isEmpty
  12. }
  13. }
  14. extension String: Occupiable { }
  15. // I can't think of a way to combine these collection types. Suggestions welcomed!
  16. extension Array: Occupiable { }
  17. extension Dictionary: Occupiable { }
  18. extension Set: Occupiable { }