Skip to content

Commit

Permalink
refactor: do not constrain PacketIdBindings with ContainsDistinctT
Browse files Browse the repository at this point in the history
See #40 (comment) for why we are doing this.
  • Loading branch information
kory33 committed Mar 6, 2022
1 parent fd6b037 commit 72c53bb
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 72c53bb

Please sign in to comment.