Generalized `enumerate` to allow user-specified enumerator type