MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / replace_child

Method replace_child

atomic-core/src/output/alive/graph.rs:265–281  ·  view source on GitHub ↗

Replace the child entry `old` of `id` with `new`, whether it sits in the contiguous child range or among the extra edges. Returns whether an entry changed. Replacing with [`VertexId::DUMMY`] drops the child: every consumer skips dummy entries.

(&mut self, id: VertexId, old: VertexId, new: VertexId)

Source from the content-addressed store, hash-verified

263 /// Returns whether an entry changed. Replacing with [`VertexId::DUMMY`]
264 /// drops the child: every consumer skips dummy entries.
265 pub fn replace_child(&mut self, id: VertexId, old: VertexId, new: VertexId) -> bool {
266 let (start, count) = {
267 let vertex = &self.vertices[id.index()];
268 (vertex.children, vertex.n_children)
269 };
270 let replaced = self.children[start..start + count]
271 .iter_mut()
272 .chain(self.vertices[id.index()].extra.iter_mut())
273 .find(|(_, child)| *child == old);
274 match replaced {
275 Some(entry) => {
276 entry.1 = new;
277 true
278 }
279 None => false,
280 }
281 }
282
283 pub fn get_vertex_mut(&mut self, id: VertexId) -> Option<&mut AliveVertex> {
284 self.vertices.get_mut(id.index())

Callers 1

attach_bypass_childFunction · 0.80

Calls 2

iter_mutMethod · 0.80
indexMethod · 0.45

Tested by

no test coverage detected