eu.timepit.refined.internal.ToInt.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of refined_sjs1_3 Show documentation
Show all versions of refined_sjs1_3 Show documentation
Simple refinement types for Scala
The newest version!
package eu.timepit.refined.internal
import scala.compiletime.erasedValue
import scala.compiletime.ops.int.S
trait ToInt[N <: Int] {
def apply(): Int
}
object ToInt {
def apply[N <: Int](implicit toInt: ToInt[N]): ToInt[N] = toInt
inline implicit def materialize[N <: Int]: ToInt[N] =
() => toInt[N]
private inline def toInt[N <: Int]: Int =
inline erasedValue[N] match {
case _: 0 => 0
case _: S[n] => toInt[n] + 1
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy