Use slices and iterators whenever possible, to avoid pointless allocation.

- Remove superfluous vec! and as_slice() where using just a slice works fine.
- Return a custom iterator rather than collect immediately to a Vec.