Expand description
§use-path
Practical path utility primitives for RustUse.
§Experimental
use-path is experimental while the use-fs workspace remains below 0.3.0.
§Example
use use_path::{PathKind, normalize_path_separators, path_kind};
assert_eq!(path_kind("C:/Users/example"), PathKind::Absolute);
assert_eq!(normalize_path_separators(r"src\lib.rs"), "src/lib.rs");§Scope
- lexical path classification
- separator detection and normalization
- simple path joining and splitting
- parent, file-name, and extension extraction
§Non-goals
- filesystem access
- canonicalization against the live filesystem
- shell expansion
- symlink resolution
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Structs§
- Path
Parts - A lexical view of a path-like input.
Enums§
- Path
Kind - Classifies a path-like input using a small lexical model.
- Path
Separator - Describes which separator styles appear in a path-like input.
Functions§
- detect_
path_ separator - Detects which path separator style appears in the input.
- ensure_
trailing_ separator - Ensures a trailing
/for non-empty input. - extension_
from_ path - Extracts the final simple extension from a path-like input.
- file_
name_ from_ path - Extracts the final file-name segment from a path-like input.
- is_
absolute_ path - Returns
truewhen the input begins with a recognized absolute prefix. - is_
empty_ path - Returns
truewhen the input is empty. - is_
relative_ path - Returns
truewhen the input is non-empty and not absolute. - join_
path_ parts - Joins path parts with
/while preserving a leading absolute prefix when present. - normalize_
path_ separators - Normalizes path separators to
/. - parent_
path - Extracts the lexical parent path when one is present.
- path_
kind - Returns the lexical kind for a path-like input.
- path_
parts - Returns lexical directory, file-name, and extension parts.
- split_
path_ parts - Splits a path-like input into normalized non-empty segments.
- trim_
trailing_ separator - Removes trailing separators while preserving recognized roots.