MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / path_depth

Method path_depth

atomic-core/src/output/repo/tree.rs:405–411  ·  view source on GitHub ↗

Get the depth of a path. # Arguments `path` - Path to measure # Returns Number of path components (0 for empty path). # Example ```rust use atomic_core::output::repo::TreeCollectOptions; assert_eq!(TreeCollectOptions::path_depth(""), 0); assert_eq!(TreeCollectOptions::path_depth("file.txt"), 1); assert_eq!(TreeCollectOptions::path_depth("src/main.rs"), 2); assert_eq!(TreeCollectOptions::pat

(path: &str)

Source from the content-addressed store, hash-verified

403 /// assert_eq!(TreeCollectOptions::path_depth("a/b/c/d.rs"), 4);
404 /// ```
405 pub fn path_depth(path: &str) -> usize {
406 if path.is_empty() {
407 0
408 } else {
409 path.split('/').filter(|s| !s.is_empty()).count()
410 }
411 }
412
413 /// Check if a path exceeds the maximum depth.
414 ///

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected