1
0
Fork 0

diplomacy: add x"..." string context

Enables hex address literals containing underscores.
Converts them to BigInts.
This commit is contained in:
Henry Cook 2017-09-08 16:17:45 -07:00
parent 063ca0ed4a
commit 37c5af1c0d
1 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,13 @@ package object diplomacy
}
}
implicit class BigIntHexContext(val sc: StringContext) extends AnyVal {
def x(args: Any*): BigInt = {
val orig = sc.s(args: _*)
BigInt(orig.replace("_", ""), 16)
}
}
def SinkCardinality[T](body: Parameters => T)(implicit p: Parameters) = body(p.alterPartial {
case CardinalityInferenceDirectionKey => CardinalityInferenceDirection.SINK_TO_SOURCE
})