Appends an element created by calling `value` with the new ID, and returns that ID. This allows creating elements that depend on their own ID. # Examples ``` # use hashql_core::id::{IdVec, Id as _, newtype}; # newtype!(struct MyId(u32 is 0..=100)); let mut vec = IdVec:: ::new(); let id = vec.push_with(|id| format!("item_{}", id.as_u32())); assert_eq!(vec[id], "item_0"); ```
(&mut self, value: impl FnOnce(I) -> T)
| 357 | /// assert_eq!(vec[id], "item_0"); |
| 358 | /// ``` |
| 359 | pub fn push_with(&mut self, value: impl FnOnce(I) -> T) -> I { |
| 360 | let id = self.bound(); |
| 361 | self.raw.push(value(id)); |
| 362 | id |
| 363 | } |
| 364 | |
| 365 | /// Removes the last element from the vector and returns it, or `None` if empty. |
| 366 | /// |
no test coverage detected