@@ -16,12 +16,16 @@ package util
1616import scala .language .`2.13`
1717import scala .language .implicitConversions
1818
19+ @ deprecated(message = " ChainingSyntax will be removed in the future. Refer to `scala.util.chaining` instead." ,
20+ since = " 3.10.0" )
1921trait ChainingSyntax {
20- @ inline implicit final def scalaUtilChainingOps [A ](a : A ): ChainingOps [A ] = new ChainingOps (a)
22+ @ deprecated(message = " Use extension methods in `scala.util.chaining` instead." , since = " 3.10.0" )
23+ @ inline final def scalaUtilChainingOps [A ](a : A ): ChainingOps [A ] = new ChainingOps (a)
2124}
2225
2326/** Adds chaining methods `tap` and `pipe` to every type.
2427 */
28+ @ deprecated(message = " Use extension methods in `scala.util.chaining` instead." , since = " 3.10.0" )
2529final class ChainingOps [A ](private val self : A ) extends AnyVal {
2630 /** Applies `f` to the value for its side effects, and returns the original value.
2731 *
@@ -37,10 +41,7 @@ final class ChainingOps[A](private val self: A) extends AnyVal {
3741 * @tparam U the result type of the function `f`.
3842 * @return the original value `self`.
3943 */
40- def tap [U ](f : A => U ): A = {
41- f(self)
42- self
43- }
44+ def tap [U ](f : A => U ): A = scala.util.chaining.tap(self)(x => f(x))
4445
4546 /** Converts the value by applying the function `f`.
4647 *
@@ -62,5 +63,5 @@ final class ChainingOps[A](private val self: A) extends AnyVal {
6263 * @return a new value resulting from applying the given function
6364 * `f` to this value.
6465 */
65- def pipe [B ](f : A => B ): B = f (self)
66+ def pipe [B ](f : A => B ): B = scala.util.chaining.pipe (self)(f )
6667}
0 commit comments