Skip to main content

Crate use_dir

Crate use_dir 

Source
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§

DirectoryPath
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 true when the input refers to the current directory.
is_parent_dir
Returns true when the input refers to the parent directory.
is_root_dir
Returns true when 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 base is a prefix of path.
starts_with_dir
Returns true when the input starts with the given directory on segment boundaries.
strip_dir_trailing_separator
Removes trailing separators while preserving roots.