docs: public static Bits toBits(Consumer<BitOutputStream> fn) {
      try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        BitOutputStream out = new BitOutputStream(buffer);
        fn.accept(out);
        out.flush();
        return new Bits(buffer.toByteArray(), out.getTotalBitsWritten());
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }