Skip to content

Commit

Permalink
Some tests are passing
Browse files Browse the repository at this point in the history
  • Loading branch information
nob13 committed Mar 31, 2023
1 parent b665ef8 commit 3b99d72
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -18,18 +18,20 @@ object TrivialValidationFieldProvider {
* (Ok, that's a bit hacky)
*/
implicit inline def trivialValidationProvider[T, V <: Validator](using m: Mirror.ProductOf[V]): TrivialValidationFieldProvider[T, V] = {
val b = singleBuilder[T, V]
val b = singleBuilder[T, m.MirroredElemTypes]
new TrivialValidationFieldProvider[T, V] {
def provide(value: T): V = {
b(value)
m.fromTuple(b(value))
}
}
}

private inline def singleBuilder[T, V](using m: Mirror.ProductOf[V]): T => V = {
inline erasedValue[m.MirroredElemTypes] match {


private inline def singleBuilder[T, V <: Tuple]: T => V = {
inline erasedValue[V] match {
case _: (T *: EmptyTuple) =>
value => (value).asInstanceOf[V]
value => (value *: EmptyTuple).asInstanceOf[V]
}
}
}

0 comments on commit 3b99d72

Please sign in to comment.