Reason for putting index first and then the value in a vector insert?
⚓ Rust 📅 2025-06-19 👤 surdeus 👁️ 12Hey there,
I just want to know what is the reason for designing the vector insert functionality in such a way that first it takes the index and then takes the value like this:
vec_data.insert(index_number, actual value);
Why not make it opposite, like first insert the value at a certain index that is given below. This seemed natural to me as compared to the functionality that Rust has implemented.
vec_data.insert(actual value, index_number);
Let me know the reason behind it.
7 posts - 4 participants
🏷️ rust_feed