Reorder a function to match the synopsis order.
Factor out set_size() and assign_to().
Implement sized assign().
Implement shrink_to_fit() and alloc-aware copy.

This also fixes a bug when copying from heap to internal.