docs: def bin_to_edge_slice(s, n):
      """
      Convert a bin slice into a bin edge slice.
      """
      s = canonify_slice(s, n)
      start = s.start
      stop = s.stop
      if start > stop:
          _stop = start + 1
          start = stop + 1
          stop = _stop
      start = max(start - 1, 0)
      step = abs(s.step)
      if stop <= 1 or start >= n - 1 or stop == start + 1:
          return slice(0, None, min(step, n - 2))
      s = slice(start, stop, abs(s.step))
      if len(range(*s.indices(n - 1))) < 2:
          return slice(start, stop, stop - start - 1)
      return s