get_dir_ancestor_that_exists

Function get_dir_ancestor_that_exists 

Source
pub fn get_dir_ancestor_that_exists<T: Debug + Display>(
    arg_string_path: &T,
) -> Option<String>
Expand description

Returns a string or None which is the part of the argument path that actually exists

§Arguments

  • arg_string_path: string-like path

§Examples

let result = match get_dir_ancestor_that_exists( &“/A/B/C” ) { Some( string_result ) => { string_result } None => { panic!( “Failed to get ancestor” ) } }; // The returned string will be “/A/B/C” if it exists // The returned string will be “/A/B” if it exists and “/A/B/C” does not // The returned string will be “/A” if all in-between paths do not exist