An open API service indexing awesome lists of open source software.

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

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(())
}
```