I think it would be quite easy, as one just has to move the Thing's as they are
consumed from each seq or table:
proc split(things: seq[T]): tuple[even, odd: seq[T]] =
var counter = newTableCount[T]()
for thing in things:
inc(counter[move thing])
for thing, count in counter:
if count mod 2 == 0:
result.even.add(move thing)
else:
result.odd.add(move thing)
Run
It could very well be that the moves are automatic as the parameters for adding
new elements in tables and seq's would have to be sink, so the compiler should
recognize that the move is necessary to move it from a sink to a sink.
Since both ref and non-ref types have copy and move implementations, then there
should be no need for separate implementations in your code.