MCPcopy Create free account
hub / github.com/csskit/csskit / find_ancestor_at_depth

Method find_ancestor_at_depth

crates/csskit/src/commands/tree.rs:85–87  ·  view source on GitHub ↗

Find the index of the ancestor at the given depth, searching backwards from `start_idx`.

(&self, start_idx: usize, target_depth: usize)

Source from the content-addressed store, hash-verified

83
84 /// Find the index of the ancestor at the given depth, searching backwards from `start_idx`.
85 fn find_ancestor_at_depth(&self, start_idx: usize, target_depth: usize) -> Option<usize> {
86 (0..start_idx).rev().find(|&j| self.nodes[j].depth == target_depth)
87 }
88
89 /// Check if `node_idx` is the last direct child of its parent.
90 fn is_last_child(&self, node_idx: usize) -> bool {

Callers 2

is_last_childMethod · 0.80
build_prefixMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected