Skip to content

Commit d4904a7

Browse files
EugeneFlesselleWojciechMazur
authored andcommitted
Add an infix shorthand for Tuple.Append
Addressing #19175 [Cherry-picked 74349e8]
1 parent 50694ca commit d4904a7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/src/scala/Tuple.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ sealed trait Tuple extends Product {
2222
runtime.Tuples.toIArray(this)
2323

2424
/** Return a copy of `this` tuple with an element appended */
25-
inline def :* [This >: this.type <: Tuple, L] (x: L): Append[This, L] =
26-
runtime.Tuples.append(x, this).asInstanceOf[Append[This, L]]
25+
inline def :* [This >: this.type <: Tuple, L] (x: L): This :* L =
26+
runtime.Tuples.append(x, this).asInstanceOf[This :* L]
2727

2828
/** Return a new tuple by prepending the element to `this` tuple.
2929
* This operation is O(this.size)
@@ -118,6 +118,9 @@ object Tuple {
118118
case x *: xs => x *: Append[xs, Y]
119119
}
120120

121+
/** An infix shorthand for `Append[X, Y]` */
122+
infix type :*[X <: Tuple, Y] = Append[X, Y]
123+
121124
/** Type of the head of a tuple */
122125
type Head[X <: Tuple] = X match {
123126
case x *: _ => x

0 commit comments

Comments
 (0)