@@ -31,6 +31,30 @@ sealed trait Tuple extends Product:
31
31
inline def *: [H , This >: this .type <: Tuple ](x : H ): H *: This =
32
32
runtime.Tuples .cons(x, this ).asInstanceOf [H *: This ]
33
33
34
+ /** Get the i-th element of this tuple.
35
+ * Equivalent to productElement but with a precise return type.
36
+ */
37
+ inline def apply [This >: this .type <: Tuple ](n : Int ): Elem [This , n.type ] =
38
+ runtime.Tuples .apply(this , n).asInstanceOf [Elem [This , n.type ]]
39
+
40
+ /** Get the head of this tuple */
41
+ inline def head [This >: this .type <: Tuple ]: Head [This ] =
42
+ runtime.Tuples .apply(this , 0 ).asInstanceOf [Head [This ]]
43
+
44
+ /** Get the initial part of the tuple without its last element */
45
+ inline def init [This >: this .type <: Tuple ]: Init [This ] =
46
+ runtime.Tuples .init(this ).asInstanceOf [Init [This ]]
47
+
48
+ /** Get the last of this tuple */
49
+ inline def last [This >: this .type <: Tuple ]: Last [This ] =
50
+ runtime.Tuples .last(this ).asInstanceOf [Last [This ]]
51
+
52
+ /** Get the tail of this tuple.
53
+ * This operation is O(this.size)
54
+ */
55
+ inline def tail [This >: this .type <: Tuple ]: Tail [This ] =
56
+ runtime.Tuples .tail(this ).asInstanceOf [Tail [This ]]
57
+
34
58
/** Return a new tuple by concatenating `this` tuple with `that` tuple.
35
59
* This operation is O(this.size + that.size)
36
60
*/
@@ -375,33 +399,7 @@ case object EmptyTuple extends Tuple {
375
399
}
376
400
377
401
/** Tuple of arbitrary non-zero arity */
378
- sealed trait NonEmptyTuple extends Tuple {
379
- import Tuple .*
380
-
381
- /** Get the i-th element of this tuple.
382
- * Equivalent to productElement but with a precise return type.
383
- */
384
- inline def apply [This >: this .type <: NonEmptyTuple ](n : Int ): Elem [This , n.type ] =
385
- runtime.Tuples .apply(this , n).asInstanceOf [Elem [This , n.type ]]
386
-
387
- /** Get the head of this tuple */
388
- inline def head [This >: this .type <: NonEmptyTuple ]: Head [This ] =
389
- runtime.Tuples .apply(this , 0 ).asInstanceOf [Head [This ]]
390
-
391
- /** Get the initial part of the tuple without its last element */
392
- inline def init [This >: this .type <: NonEmptyTuple ]: Init [This ] =
393
- runtime.Tuples .init(this ).asInstanceOf [Init [This ]]
394
-
395
- /** Get the last of this tuple */
396
- inline def last [This >: this .type <: NonEmptyTuple ]: Last [This ] =
397
- runtime.Tuples .last(this ).asInstanceOf [Last [This ]]
398
-
399
- /** Get the tail of this tuple.
400
- * This operation is O(this.size)
401
- */
402
- inline def tail [This >: this .type <: NonEmptyTuple ]: Tail [This ] =
403
- runtime.Tuples .tail(this ).asInstanceOf [Tail [This ]]
404
- }
402
+ sealed trait NonEmptyTuple extends Tuple
405
403
406
404
@ showAsInfix
407
405
sealed abstract class *: [+ H , + T <: Tuple ] extends NonEmptyTuple
0 commit comments