Empty.swift 676 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // Empty.swift
  3. // EmptyKit-Swift
  4. //
  5. // Created by archerzz on 16/11/16.
  6. // Copyright © 2016年 archerzz. All rights reserved.
  7. //
  8. import Foundation
  9. import UIKit
  10. /// Empty
  11. public final class Empty<Base> {
  12. public let base: Base
  13. public init(_ base: Base) {
  14. self.base = base
  15. }
  16. }
  17. /**
  18. A type that has Empty extensions.
  19. */
  20. public protocol EmptyCompatible {
  21. associatedtype CompatibleType
  22. var ept: CompatibleType { get }
  23. }
  24. // MARK: - EmptyCompatible
  25. public extension EmptyCompatible {
  26. public var ept: Empty<Self> {
  27. get { return Empty(self) }
  28. }
  29. }
  30. // MARK: - UIScrollView EmptyCompatible
  31. extension UIScrollView: EmptyCompatible {}