I don't really like having this function mutate its args.

If you want to keep it that way, could you at least make the non-const ref a pointer to make the mutation more explicit?