Skip to main content

find_common_prefix

Function find_common_prefix 

Source
pub fn find_common_prefix<'a>(
    paths: impl Iterator<Item = &'a str>,
) -> Option<String>
Expand description

Find the longest common directory prefix among absolute file paths.

Only considers absolute paths (starting with /). Splits by / and finds common path components. Returns the common prefix with a trailing /. Returns None if no common prefix exists or fewer than 2 paths are provided.