Drain
— wait, this is seeming familiar. Let’s do some more compression. BothIntoIter and Drain have the exact same structure, let’s just factor it out.
Note that I’ve left a few quirks in this design to make upgrading Drain to workwith arbitrary subranges a bit easier. In particular we could have RawValIterdrain itself on drop, but that won’t work right for a more complex Drain.We also take a slice to simplify Drain initialization.
For more details on the problem, see thesection on leaks.