Inserts a value at the given ID index, expanding the vector if necessary. If the vector is shorter than the index, it will be extended with `None` values. This enables sparse, map-like usage patterns. # Examples ``` # use hashql_core::id::{IdVec, Id as _, newtype}; # newtype!(struct MyId(u32 is 0..=0xFFFF_FF00)); let mut vec = IdVec:: >::new(); vec.insert(MyId::from_usize(5)
(&mut self, index: I, value: T)
| 539 | /// assert_eq!(vec[MyId::from_usize(5)].as_ref().unwrap(), "hello"); |
| 540 | /// ``` |
| 541 | pub fn insert(&mut self, index: I, value: T) -> Option<T> { |
| 542 | self.fill_until(index, || None).replace(value) |
| 543 | } |
| 544 | |
| 545 | /// Gets the value at `index`, or inserts one by calling `value` if it doesn't exist. |
| 546 | /// |
no test coverage detected