TupleExtensions.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // TupleExtensions.swift
  3. // ReactiveSwift
  4. //
  5. // Created by Justin Spahr-Summers on 2014-12-20.
  6. // Copyright (c) 2014 GitHub. All rights reserved.
  7. //
  8. /// Adds a value into an N-tuple, returning an (N+1)-tuple.
  9. ///
  10. /// Supports creating tuples up to 10 elements long.
  11. internal func repack<A, B, C>(_ t: (A, B), value: C) -> (A, B, C) {
  12. return (t.0, t.1, value)
  13. }
  14. internal func repack<A, B, C, D>(_ t: (A, B, C), value: D) -> (A, B, C, D) {
  15. return (t.0, t.1, t.2, value)
  16. }
  17. internal func repack<A, B, C, D, E>(_ t: (A, B, C, D), value: E) -> (A, B, C, D, E) {
  18. return (t.0, t.1, t.2, t.3, value)
  19. }
  20. internal func repack<A, B, C, D, E, F>(_ t: (A, B, C, D, E), value: F) -> (A, B, C, D, E, F) {
  21. return (t.0, t.1, t.2, t.3, t.4, value)
  22. }
  23. internal func repack<A, B, C, D, E, F, G>(_ t: (A, B, C, D, E, F), value: G) -> (A, B, C, D, E, F, G) {
  24. return (t.0, t.1, t.2, t.3, t.4, t.5, value)
  25. }
  26. internal func repack<A, B, C, D, E, F, G, H>(_ t: (A, B, C, D, E, F, G), value: H) -> (A, B, C, D, E, F, G, H) {
  27. return (t.0, t.1, t.2, t.3, t.4, t.5, t.6, value)
  28. }
  29. internal func repack<A, B, C, D, E, F, G, H, I>(_ t: (A, B, C, D, E, F, G, H), value: I) -> (A, B, C, D, E, F, G, H, I) {
  30. return (t.0, t.1, t.2, t.3, t.4, t.5, t.6, t.7, value)
  31. }
  32. internal func repack<A, B, C, D, E, F, G, H, I, J>(_ t: (A, B, C, D, E, F, G, H, I), value: J) -> (A, B, C, D, E, F, G, H, I, J) {
  33. return (t.0, t.1, t.2, t.3, t.4, t.5, t.6, t.7, t.8, value)
  34. }