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

Function parent_directory_among

atomic-agent/src/record/mod.rs:1017–1026  ·  view source on GitHub ↗

The first parent directory of a path in `paths` that is itself a path in `others`.

(
    paths: &std::collections::BTreeSet<&'a str>,
    others: &std::collections::BTreeSet<&'a str>,
)

Source from the content-addressed store, hash-verified

1015/// The first parent directory of a path in `paths` that is itself a path in
1016/// `others`.
1017fn parent_directory_among<'a>(
1018 paths: &std::collections::BTreeSet<&'a str>,
1019 others: &std::collections::BTreeSet<&'a str>,
1020) -> Option<&'a str> {
1021 paths.iter().find_map(|path| {
1022 path.match_indices('/')
1023 .map(|(end, _)| &path[..end])
1024 .find(|parent| others.contains(parent))
1025 })
1026}
1027
1028/// Why recording this turn would NOT reproduce `commit` exactly, or `None`
1029/// when it would (CB-12A follow-up AC-8).

Callers 1

file_directory_swapFunction · 0.85

Calls 2

iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected