Skip to content

Commit

Permalink
Forgot some code
Browse files Browse the repository at this point in the history
  • Loading branch information
nob13 committed Mar 31, 2023
1 parent ac761f8 commit 783528b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions schema/src/main/scala-3/net/reactivecore/cjs/util/Derivation.scala
@@ -0,0 +1,19 @@
package net.reactivecore.cjs.util
import scala.compiletime.{erasedValue, summonInline}
import scala.deriving.Mirror

object Derivation {

inline def deriveLabels[T](using m: Mirror.Of[T]): List[String] = {
// Also See https://stackoverflow.com/a/70416544/335385
summonLabels[m.MirroredElemLabels]
}

inline def summonLabels[T <: Tuple]: List[String] = {
inline erasedValue[T] match {
case _: EmptyTuple => Nil
case _: (t *: ts) => summonInline[ValueOf[t]].value.asInstanceOf[String] :: summonLabels[ts]
}
}

}

0 comments on commit 783528b

Please sign in to comment.