Expand description
§use-dir
Practical directory path utility primitives for RustUse.
§Experimental
use-dir is experimental while the use-fs workspace remains below 0.3.0.
§Example
use use_dir::{ensure_dir_trailing_separator, path_depth};
assert_eq!(ensure_dir_trailing_separator("docs/guides"), "docs/guides/");
assert_eq!(path_depth("docs/guides/getting-started"), 3);§Scope
- lexical directory helpers
- root, current, and parent directory checks
- trailing-separator normalization
- directory-oriented prefix and relative-path helpers
§Non-goals
- directory creation or reading
- directory walking
- symlink resolution
- filesystem permission management
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Structs§
- Directory
Path - A string-backed directory path.
Functions§
- dir_
name - Extracts the most relevant directory segment from a path-like input.
- ensure_
dir_ trailing_ separator - Ensures a trailing
/for non-empty directory paths. - is_
current_ dir - Returns
truewhen the input refers to the current directory. - is_
parent_ dir - Returns
truewhen the input refers to the parent directory. - is_
root_ dir - Returns
truewhen the input is a recognized root directory. - normalize_
dir_ path - Normalizes directory separators to
/and removes trailing separators unless the input is a root. - path_
depth - Returns the lexical depth of a directory path.
- relative_
to_ dir - Computes a lexical relative path when
baseis a prefix ofpath. - starts_
with_ dir - Returns
truewhen the input starts with the given directory on segment boundaries. - strip_
dir_ trailing_ separator - Removes trailing separators while preserving roots.