checkNoDuplicates = (elements, fullCompare, check) => {
  // This fullOrder contains history dependent state. It is specific
  // to this one call and does not survive it.
  // TODO Once all our tooling is ready for `&&=`, the following
  // line should be rewritten using it.
  fullCompare = fullCompare || makeFullOrderComparatorKit().antiComparator;

  elements = sortByRank(elements, fullCompare);
  const { length } = elements;
  for (let i = 1; i < length; i += 1) {
    const k0 = elements[i - 1];
    const k1 = elements[i];
    if (fullCompare(k0, k1) === 0) {
      return check(false, X`value has duplicate keys: ${k0}`);
    }
  }
  return true;
}
@template {Passable} T
@param {T[]} elements
@param {FullCompare | undefined} fullCompare If provided and `elements` is already known
to be sorted by this `fullCompare`, then we should get a memo hit rather
than a resorting. However, currently, we still enumerate the entire array
each time.

TODO: If doing this reduntantly turns out to be expensive, we
could memoize this no-duplicate finding as well, independent
of the `fullOrder` use to reach this finding.
@param {Checker} check
@returns {boolean}