pub fn rehash(&mut self) {
        self.clear();

        if let Ok(value) = env::var("PATH") {
            let dirs: Vec<&str> = value.split(':').filter(|x| !x.is_empty()).collect();
            for dir in dirs {
                let path = Path::new(dir);
                if !path.exists() || !path.is_dir() {
                    continue;
                }

                // Find executable files at the top-level of the directory.
                if let Ok(rd) = fs::read_dir(dir) {
                    for entry in rd.flatten() {
                        let path = entry.path();
                        if path.is_file() && path.is_executable() {
                            if let Some(file_name) = path.file_name().unwrap().to_str() {
                                self.insert(file_name.to_string());
                            }
                        }
                    }
                }
            }
        }
    }
/// Finds all executable programs in $PATH and adds the base file names to the internal set.
Finds all executable programs in $PATH and adds the base file names to the internal set.
Finds all executable programs in $PATH and adds the base file names to the internal set .
pub fn rehash(&mut self) {
        self.clear();
        if let Ok(value) = env::var("PATH") {
            let dirs: Vec<&str> = value.split(':').filter(|x| !x.is_empty()).collect();
            for dir in dirs {
                let path = Path::new(dir);
                if !path.exists() || !path.is_dir() {
                    continue;
                }
                // Find executable files at the top-level of the directory.
                if let Ok(rd) = fs::read_dir(dir) {
                    for entry in rd.flatten() {
                        let path = entry.path();
                        if path.is_file() && path.is_executable() {
                            if let Some(file_name) = path.file_name().unwrap().to_str() {
                                self.insert(file_name.to_string());
                            }
                        }
                    }
                }
            }
        }
    }
pub fn rehash ( & mut self ) { self . clear ( ) ; if let Ok ( value ) = env :: var ( " " ) { let dirs : Vec < & str > = value . split ( ':' ) . filter ( | x | ! x . is_empty ( ) ) . collect ( ) ; for dir in dirs { let path = Path :: new ( dir ) ; if ! path . exists ( ) || ! path . is_dir ( ) { continue ; } // Find executable files at the top-level of the directory. if let Ok ( rd ) = fs :: read_dir ( dir ) { for entry in rd . flatten ( ) { let path = entry . path ( ) ; if path . is_file ( ) && path . is_executable ( ) { if let Some ( file_name ) = path . file_name ( ) . unwrap ( ) . to_str ( ) { self . insert ( file_name . to_string ( ) ) ; } } } } } } }
Finds all executable programs in $PATH and adds the base file names to the internal set.
Finds all executable programs in $PATH and adds the base file names to the internal set .
&mut self