@@ -31,6 +31,30 @@ sealed trait Tuple extends Product {
3131 inline def *: [H , This >: this .type <: Tuple ] (x : H ): H *: This =
3232 runtime.Tuples .cons(x, this ).asInstanceOf [H *: This ]
3333
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+
3458 /** Return a new tuple by concatenating `this` tuple with `that` tuple.
3559 * This operation is O(this.size + that.size)
3660 */
@@ -304,33 +328,7 @@ case object EmptyTuple extends Tuple {
304328}
305329
306330/** Tuple of arbitrary non-zero arity */
307- sealed trait NonEmptyTuple extends Tuple {
308- import Tuple .*
309-
310- /** Get the i-th element of this tuple.
311- * Equivalent to productElement but with a precise return type.
312- */
313- inline def apply [This >: this .type <: NonEmptyTuple ](n : Int ): Elem [This , n.type ] =
314- runtime.Tuples .apply(this , n).asInstanceOf [Elem [This , n.type ]]
315-
316- /** Get the head of this tuple */
317- inline def head [This >: this .type <: NonEmptyTuple ]: Head [This ] =
318- runtime.Tuples .apply(this , 0 ).asInstanceOf [Head [This ]]
319-
320- /** Get the initial part of the tuple without its last element */
321- inline def init [This >: this .type <: NonEmptyTuple ]: Init [This ] =
322- runtime.Tuples .init(this ).asInstanceOf [Init [This ]]
323-
324- /** Get the last of this tuple */
325- inline def last [This >: this .type <: NonEmptyTuple ]: Last [This ] =
326- runtime.Tuples .last(this ).asInstanceOf [Last [This ]]
327-
328- /** Get the tail of this tuple.
329- * This operation is O(this.size)
330- */
331- inline def tail [This >: this .type <: NonEmptyTuple ]: Tail [This ] =
332- runtime.Tuples .tail(this ).asInstanceOf [Tail [This ]]
333- }
331+ sealed trait NonEmptyTuple extends Tuple
334332
335333@ showAsInfix
336334sealed abstract class *: [+ H , + T <: Tuple ] extends NonEmptyTuple
0 commit comments