We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc5c09b commit 4408853Copy full SHA for 4408853
library/src/scala/Conversion.scala
@@ -17,10 +17,16 @@ package scala
17
* Also note that in bootstrapped dotty, `Predef.<:<` should inherit from
18
* `Conversion`. This would cut the number of special cases in `discardForView`
19
* from two to one.
20
+*
21
+* The `Conversion` class can also be used to convert explicitly, using
22
+* the `into` extension method.
23
*/
24
@java.lang.FunctionalInterface
25
abstract class Conversion[-T, +U] extends Function1[T, U]:
26
+ /** Convert value `x` of type `T` to type `U` */
27
def apply(x: T): U
28
object Conversion:
29
+
30
extension [T](x: T)
31
+ /** `x.into[U]` converts a value `x` of type `T` to type `U` */
32
def into[U](using c: Conversion[T, U]) = c(x)
0 commit comments