diff options
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/ext.rs | 9 | ||||
| -rw-r--r-- | src/libstd/sys/unix/fs2.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process2.rs | 2 |
3 files changed, 4 insertions, 11 deletions
diff --git a/src/libstd/sys/unix/ext.rs b/src/libstd/sys/unix/ext.rs index 080cf5620fc..fbfbb40701f 100644 --- a/src/libstd/sys/unix/ext.rs +++ b/src/libstd/sys/unix/ext.rs @@ -207,7 +207,7 @@ pub mod io { /// Unix-specific extension to the primitives in the `std::ffi` module #[stable(feature = "rust1", since = "1.0.0")] pub mod ffi { - use ffi::{CString, NulError, OsStr, OsString}; + use ffi::{OsStr, OsString}; use mem; use prelude::v1::*; use sys::os_str::Buf; @@ -244,10 +244,6 @@ pub mod ffi { /// Get the underlying byte view of the `OsStr` slice. #[stable(feature = "rust1", since = "1.0.0")] fn as_bytes(&self) -> &[u8]; - - /// Convert the `OsStr` slice into a `CString`. - #[stable(feature = "rust1", since = "1.0.0")] - fn to_cstring(&self) -> Result<CString, NulError>; } #[stable(feature = "rust1", since = "1.0.0")] @@ -258,9 +254,6 @@ pub mod ffi { fn as_bytes(&self) -> &[u8] { &self.as_inner().inner } - fn to_cstring(&self) -> Result<CString, NulError> { - CString::new(self.as_bytes()) - } } } diff --git a/src/libstd/sys/unix/fs2.rs b/src/libstd/sys/unix/fs2.rs index 80fc1235a31..c5d3dce2634 100644 --- a/src/libstd/sys/unix/fs2.rs +++ b/src/libstd/sys/unix/fs2.rs @@ -276,8 +276,8 @@ impl File { } fn cstr(path: &Path) -> io::Result<CString> { - let cstring = try!(path.as_os_str().to_cstring()); - Ok(cstring) + path.as_os_str().to_cstring().ok_or( + io::Error::new(io::ErrorKind::InvalidInput, "path contained a null", None)) } impl FromInner<c_int> for File { diff --git a/src/libstd/sys/unix/process2.rs b/src/libstd/sys/unix/process2.rs index 20c409154b8..c2a8b26aef4 100644 --- a/src/libstd/sys/unix/process2.rs +++ b/src/libstd/sys/unix/process2.rs @@ -54,7 +54,7 @@ impl Command { self.args.push(arg.to_cstring().unwrap()) } pub fn args<'a, I: Iterator<Item = &'a OsStr>>(&mut self, args: I) { - self.args.extend(args.map(|s| OsStrExt::to_cstring(s).unwrap())) + self.args.extend(args.map(|s| s.to_cstring().unwrap())) } fn init_env_map(&mut self) { if self.env.is_none() { |
