get_dir_ancestor_n_levels_up

Function get_dir_ancestor_n_levels_up 

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

Returns a string or None which is the path n-layers up

§Arguments

  • arg_string_path: string-like path
  • arg_n: usize-type value representing the number of layers to iterate through

§Examples

let result = match get_dir_ancestor_n_levels_up( &“/A/B/C”, 2 ) { Some( string_result ) => { string_result } None => { panic!( “Failed to get ancestor” ) } }; // result = “/A”