We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f778523 commit 2170b51Copy full SHA for 2170b51
src/lib.rs
@@ -73,7 +73,7 @@ pub mod unistd;
73
74
use libc::c_char;
75
use std::{ptr, result};
76
-use std::ffi::{CStr, OsStr};
+use std::ffi::{CStr, CString, OsStr};
77
use std::path::{Path, PathBuf};
78
use std::os::unix::ffi::OsStrExt;
79
use std::fmt;
@@ -196,6 +196,17 @@ impl NixPath for CStr {
196
}
197
198
199
+impl NixPath for CString {
200
+ fn len(&self) -> usize {
201
+ self.to_bytes().len()
202
+ }
203
+
204
+ fn with_nix_path<T, F>(&self, f: F) -> Result<T>
205
+ where F: FnOnce(&CStr) -> T {
206
+ self.as_c_str().with_nix_path(f)
207
208
+}
209
210
impl NixPath for [u8] {
211
fn len(&self) -> usize {
212
self.len()
0 commit comments