no_std_path
A no_std fork of Rust's std::path module, providing cross-platform path manipulation without the standard library.
Overview
no_std_path provides Path, PathBuf, OsStr, OsString, and the full suite of component/iterator types (Components, Ancestors, Prefix, etc.) adapted from the Rust standard library. It supports parsing, joining, decomposing, and comparing paths on both Unix and Windows.
Most of the code is derived from the Rust standard library with modifications to remove std dependencies.
Features
| Feature | Default | Description |
|---|---|---|
std |
Yes | Re-exports types directly from std::path and std::ffi, giving full platform support and filesystem methods. |
When std is disabled, lightweight custom implementations are provided using only core and alloc. This mode is suitable for embedded and no_std targets such as thumbv7m-none-eabi.
Usage
With the std feature (default):
[]
= "0.1"
For no_std environments:
[]
= { = "0.1", = false }
Example
use ;
let path = new;
assert_eq!;
assert_eq!;
let mut buf = from;
buf.push;
buf.push;
assert_eq!;
Differences from std::path
In no_std mode (with std feature disabled):
- No filesystem methods — Methods like
exists(),canonicalize(),metadata(),read_link(),is_file(), andis_dir()are not available since they require OS interaction. OsStr/OsStringare[u8]/Vec<u8>wrappers — The standard library's platform-encoded OS strings are replaced with simple byte-slice newtypes. This means all paths are treated as byte sequences (matching Unix semantics) rather than using platform-specific encoding.
When the std feature is enabled, all types are re-exported from std::path and std::ffi directly, so behavior is identical to the standard library.
Minimum Supported Rust Version
This crate uses Rust edition 2024.
License
Licensed under either of
at your option.
Most code is derived from the Rust standard library, which is also dual-licensed under MIT and Apache 2.0.