You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often need to get to know If two slices are comprised of the same set of elements.
There's a similar helper in testify package: ElementsMatch.
The proposal:
// ElementsMatch returns true if lists// contain the same set of elements (including empty set).// // If there are duplicate elements,// the number of appearances of each of them in both lists should match.funcElementsMatch[Tcomparable, Slice~[]T](list1Slice, list2Slice) bool// ElementsMatchBy returns true if lists// contain the same set of elements' keys (including empty set).// // If there are duplicate keys,// the number of appearances of each of them in both lists should match.funcElementsMatchBy[Tany, Kcomparable](list1 []T, list2 []T, iterateefunc(itemT) K) bool
To implement ElementsMatch we could make use of Keyify.
To implement ElementsMatchBy some new code is needed.
The text was updated successfully, but these errors were encountered:
I often need to get to know If two slices are comprised of the same set of elements.
There's a similar helper in testify package: ElementsMatch.
The proposal:
To implement
ElementsMatch
we could make use ofKeyify
.To implement
ElementsMatchBy
some new code is needed.The text was updated successfully, but these errors were encountered: