All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.timepit.refined.internal.ToInt.scala Maven / Gradle / Ivy

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