MCPcopy Create free account
hub / github.com/Michael-F-Bryan/include_dir / get_entry

Method get_entry

include_dir/src/dir.rs:40–56  ·  view source on GitHub ↗

Recursively search for a [`DirEntry`] with a particular path.

(&self, path: S)

Source from the content-addressed store, hash-verified

38
39 /// Recursively search for a [`DirEntry`] with a particular path.
40 pub fn get_entry<S: AsRef<Path>>(&self, path: S) -> Option<&'a DirEntry<'a>> {
41 let path = path.as_ref();
42
43 for entry in self.entries() {
44 if entry.path() == path {
45 return Some(entry);
46 }
47
48 if let DirEntry::Dir(d) = entry {
49 if let Some(nested) = d.get_entry(path) {
50 return Some(nested);
51 }
52 }
53 }
54
55 None
56 }
57
58 /// Look up a file by name.
59 pub fn get_file<S: AsRef<Path>>(&self, path: S) -> Option<&'a File<'a>> {

Callers 4

get_fileMethod · 0.80
get_dirMethod · 0.80
containsMethod · 0.80
validate_includedFunction · 0.80

Calls 2

entriesMethod · 0.80
pathMethod · 0.45

Tested by 1

validate_includedFunction · 0.64