From 72c53bbc30c60f26b1830651e89976db16de516b Mon Sep 17 00:00:00 2001 From: Kory Date: Sun, 6 Mar 2022 01:04:12 +0000 Subject: [PATCH] refactor: do not constrain PacketIdBindings with ContainsDistinctT See https://github.com/kory33/s2mc-test/issues/40#issuecomment-1059864681 for why we are doing this. --- .../core/connection/protocol/PacketIdBindings.scala | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/protocol-core/src/main/scala/io/github/kory33/s2mctest/core/connection/protocol/PacketIdBindings.scala b/protocol-core/src/main/scala/io/github/kory33/s2mctest/core/connection/protocol/PacketIdBindings.scala index 70d18ff3..c1dd0ca0 100644 --- a/protocol-core/src/main/scala/io/github/kory33/s2mctest/core/connection/protocol/PacketIdBindings.scala +++ b/protocol-core/src/main/scala/io/github/kory33/s2mctest/core/connection/protocol/PacketIdBindings.scala @@ -14,12 +14,12 @@ type CodecBinding[A] = (PacketId, ByteCodec[A]) /** * An object that associates packet IDs with corresponding datatypes' codec. * - * [[PacketTup]] is a tuple of packets with no duplicates, used in associating codecs. It is - * also required that [[bindings]] should not contain two entries with the same packet ID. + * [[PacketTup]] is a tuple of packets with no duplicates, and is used in associating codecs. It + * is also required that [[bindings]] should not contain two entries with the same packet ID. */ class PacketIdBindings[PacketTup <: Tuple]( bindings: Tuple.Map[PacketTup, CodecBinding] -)(using Require[ContainsDistinctT[PacketTup]]) { +) { require( { @@ -65,12 +65,8 @@ class PacketIdBindings[PacketTup <: Tuple]( } object PacketIdBindings { - def apply[BindingsTup <: Tuple]( - bindingsTup: BindingsTup - )( + def apply[BindingsTup <: Tuple](bindingsTup: BindingsTup)( using ev: Tuple.IsMappedBy[CodecBinding][BindingsTup] - )( - using Require[ContainsDistinctT[Tuple.InverseMap[BindingsTup, CodecBinding]]] ): PacketIdBindings[Tuple.InverseMap[BindingsTup, CodecBinding]] = { new PacketIdBindings[InverseMap[BindingsTup, CodecBinding]]( ev(bindingsTup)