fn extend_desugared<I: Iterator<Item = T>>(&mut self, mut iterator: I) {
        // This is the case for a general iterator.
        //
        // This function should be the moral equivalent of:
        //
        //      for item in iterator {
        //          self.push(item);
        //      }
        while let Some(element) = iterator.next() {
            let len = self.len();
            if len == self.capacity() {
                let (lower, _) = iterator.size_hint();
                self.reserve(lower.saturating_add(1));
            }
            unsafe {
                ptr::write(self.as_mut_ptr().add(len), element);
                // NB can't overflow since we would have had to alloc the address space
                self.set_len(len + 1);
            }
        }
    }
Creates an iterator which uses a closure to determine if an element should be removed.

If the closure returns true, then the element is removed and yielded.
If the closure returns false, the element will remain in the vector and will not be yielded
by the iterator.

Using this method is equivalent to the following code:
benchmarks/haystacks/code/rust-library.rs