https://github.com/freaky/osstrops
Safe cross-platform string operations on OsStr
https://github.com/freaky/osstrops
Last synced: 3 days ago
JSON representation
Safe cross-platform string operations on OsStr
- Host: GitHub
- URL: https://github.com/freaky/osstrops
- Owner: Freaky
- License: mit
- Created: 2019-08-01T22:43:29.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-01T23:10:01.000Z (almost 7 years ago)
- Last Synced: 2025-03-02T20:30:45.190Z (over 1 year ago)
- Language: Rust
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# OsStrOps
Some basic string operations on OsStr.
On Unix, this always operates on bytes, on Windows it tries to operate on `str`,
but will fall back on `Vec` using encode/decode_wide() if necessary.
```rust
use osstrops::OsStrOps;
fn main() -> std::io::Result<()> {
for arg in std::env::args_os() {
let argop = OsStrOps::from(&arg);
if argop.starts_with("--path=") {
if let (_, Some(path)) = argop.split_at_byte(b'=') {
println!("Path: {}", path.to_string_lossy());
let _file = std::fs::File::open(path)?;
}
}
}
Ok(())
}
```