vec: with_capacity: check for overflow

Fixes #10271
auto merge of #10417 : cmr/rust/vec_overflow, r=huonw

Fixes #10271