The trick is that you can pull the non-generic parts out into separate functions. That way they don’t need to be monomorphized and can be shared between the various monomorphizations of your generic function. Surprisingly, this even works when the shared part is an inner function.