1
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

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 { def SinkCardinality[T](body: Parameters => T)(implicit p: Parameters) = body(p.alterPartial {
case CardinalityInferenceDirectionKey => CardinalityInferenceDirection.SINK_TO_SOURCE case CardinalityInferenceDirectionKey => CardinalityInferenceDirection.SINK_TO_SOURCE
}) })