Insert a node and return its current slot/generation id. Reuses a free slot when available. Otherwise appends a new slot.
(&mut self, node: SceneNode)
| 151 | pub(crate) struct ScopedNodeMut<'a> { |
| 152 | arena: &'a mut NodeArena, |
| 153 | index: usize, |
| 154 | armed: bool, |
| 155 | } |
| 156 | |
| 157 | impl ScopedNodeMut<'_> { |
| 158 | /// End a normally classified callback. Unwind before this call leaves the |
| 159 | /// guard armed so drop invalidates every dependent domain. |
| 160 | #[inline] |
| 161 | pub(crate) fn finish(mut self) { |
| 162 | self.armed = false; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | impl Deref for ScopedNodeMut<'_> { |
| 167 | type Target = SceneNode; |
| 168 | |
| 169 | fn deref(&self) -> &Self::Target { |
| 170 | self.arena.nodes[self.index] |
| 171 | .as_ref() |
| 172 | .expect("scoped node slot stays live while borrowed") |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | impl DerefMut for ScopedNodeMut<'_> { |
| 177 | fn deref_mut(&mut self) -> &mut Self::Target { |
| 178 | self.arena.nodes[self.index] |
| 179 | .as_mut() |
| 180 | .expect("scoped node slot stays live while borrowed") |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | impl Drop for ScopedNodeMut<'_> { |
| 185 | fn drop(&mut self) { |
| 186 | if self.armed { |
| 187 | self.arena.bump_world_state_revisions(); |