I’ve worked that idea in head many mornings standing in the shower watching the warm water go down the drain. My idea centers around a manifold to smaller drain pipes in parallel to increase the surface area. But I keep getting hung up on what a god-awful clog it would create in time. Next thought was to come up with a finned drain pipe similar to old school baseboard hot water heat. Then again if I switch to cold showers I won’t be thinking about it.
The way the one I referred to was described was that there was a central pipe (copper) 3” or 4” in diameter, through which the waste water flowed - spliced in to the existing drain line from the bathtub.
It, then, had another copper pipe - normal supply pipe, 1/2” or so, wound tightly on a mandrel so it was slightly deformed to increase the surface-area contact. The cold water flowed through that one on its way to the heater, and warmed significantly.
Worked well for showers, when the supply came in as the same time as the outflow; not so good for baths.