| Crates.io | macron-path |
| lib.rs | macron-path |
| version | 0.1.2 |
| created_at | 2025-07-02 13:53:14.127086+00 |
| updated_at | 2025-07-18 05:41:55.795492+00 |
| description | Creates a new instance of PathBuf |
| homepage | |
| repository | https://github.com/fuderis/rs-macron/tree/main/macron-path |
| max_upload_size | |
| id | 1735085 |
| size | 10,946 |
A macro for ergonomic and safe construction of file and directory paths in Rust, with context-aware resolution.
P.S. More useful macros are available in the macron package.
Relative to current working directory: If the path does not start with / or , it is resolved relative to the current working directory (std::env::current_dir()).
Relative to executable's directory: If the path starts with / or , it is resolved relative to the directory where the executable resides (std::env::current_exe()).
Supports formatting: You can use string formatting just like with the standard format! macro.
use macron_path::path;
// Path relative to the current working directory
let relative_path = path!("foo/bar");
// Path relative to the application executable's directory
let app_root_path = path!("/foo/bar");
// Path relative to the user data directory for saving applications data
let user_data_path = path!("$/foo/bar");
// Supports string formatting
let fmt_path = path!("foo/{}", "bar");
Windows: Both / and \ are supported as path separators.
Linux/macOS: Only / is treated as a directory separator. For best results, use / or build paths using the macro or standard library methods.
Always use the path!: macro to avoid issues with separators and path resolution differences across platforms.
Distributed under the MIT license.
You can contact me via GitHub or send a message to my Telegram @fuderis.
This library is actively evolving, and your suggestions and feedback are always welcome!
P.S. More useful macros are available in the macron package.