Provisions an ID and interns a partial representation created with that ID. This method is particularly useful for creating recursive data structures. It: 1. Provisions a new unique ID 2. Passes that ID to the provided closure 3. Interns the partial representation returned by the closure with the provisioned ID This is the most convenient way to create self-referential structures, as you can use
(&self, closure: impl FnOnce(Provisioned<T::Id>) -> T::Partial)
| 569 | /// assert_eq!(tail.next, Some(head.id())); // Tail points back to head! |
| 570 | /// ``` |
| 571 | pub fn intern(&self, closure: impl FnOnce(Provisioned<T::Id>) -> T::Partial) -> T { |
| 572 | let id = self.provision(); |
| 573 | let partial = closure(id); |
| 574 | |
| 575 | self.intern_provisioned(id, partial) |
| 576 | } |
| 577 | |
| 578 | /// Retrieves a value by its ID. |
| 579 | /// |