Skip to content

Commit

Permalink
Add an infix shorthand for Tuple.Concat
Browse files Browse the repository at this point in the history
Addressing #19175

[Cherry-picked 4e47edf]
  • Loading branch information
EugeneFlesselle authored and WojciechMazur committed Nov 18, 2024
1 parent d4904a7 commit b8a10a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/src/scala/Tuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ sealed trait Tuple extends Product {
/** Return a new tuple by concatenating `this` tuple with `that` tuple.
* This operation is O(this.size + that.size)
*/
inline def ++ [This >: this.type <: Tuple](that: Tuple): Concat[This, that.type] =
runtime.Tuples.concat(this, that).asInstanceOf[Concat[This, that.type]]
inline def ++ [This >: this.type <: Tuple](that: Tuple): This ++ that.type =
runtime.Tuples.concat(this, that).asInstanceOf[This ++ that.type]

/** Return the size (or arity) of the tuple */
inline def size[This >: this.type <: Tuple]: Size[This] =
Expand Down Expand Up @@ -150,6 +150,9 @@ object Tuple {
case x1 *: xs1 => x1 *: Concat[xs1, Y]
}

/** An infix shorthand for `Concat[X, Y]` */
infix type ++[X <: Tuple, +Y <: Tuple] = Concat[X, Y]

/** Type of the element at position N in the tuple X */
type Elem[X <: Tuple, N <: Int] = X match {
case x *: xs =>
Expand Down

0 comments on commit b8a10a4

Please sign in to comment.