Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/llogiq/pathsep
A os agnostic way to get a path separator in macros
https://github.com/llogiq/pathsep
Last synced: 3 months ago
JSON representation
A os agnostic way to get a path separator in macros
- Host: GitHub
- URL: https://github.com/llogiq/pathsep
- Owner: llogiq
- License: apache-2.0
- Created: 2018-10-26T05:07:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-19T17:36:09.000Z (about 6 years ago)
- Last Synced: 2024-08-09T15:30:51.372Z (5 months ago)
- Language: Rust
- Size: 7.81 KB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.Apache2
Awesome Lists containing this project
README
# Get the path separator for your OS
When you want to `include!(_)` generated files, cargo will ask you to
put them in `$OUT_DIR`. However, the "usual" way of```rust, ignore
include!(concat!(env!("OUT_DIR"), "/somefile.rs"));
```will fail on some windows systems, because they fail to understand the
`/` path separator. This crate allows you to replace that with:```rust, ignore
include!(join_path!(env!("OUT_DIR"), "somefile.rs"));
```This will work on all operating systems. You can create paths starting with the
separator by prepending `/` to the `join_path!` arguments:```rust, ignore
join_path!(/ "usr", "local", "lib");
```# Usage
Add this to your Cargo.toml:
```
pathsep = "0.1"
```
Then you can use `#[macro_use] extern crate pathsep;` in your crate root. As of
Rust 1.30, you can also omit the `#[macro_use]` and
`use pathsep::join_path;` directly.## License
This code is licensed under the terms of the Apache License 2.0 or the MIT
license, at your discretion.