ec::set_len requires that new_len <= capacity() This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.