diff --git a/src/common/file_descriptor.rs b/src/common/file_descriptor.rs index 33611499d..33019a6bf 100644 --- a/src/common/file_descriptor.rs +++ b/src/common/file_descriptor.rs @@ -1,8 +1,8 @@ -use std::io::Read; +use std::ffi::CString; use std::io; use std::io::Error; use std::io::ErrorKind; -use std::ffi::CString; +use std::io::Read; pub struct FileDescriptor(libc::c_int); @@ -15,14 +15,12 @@ impl FileDescriptor { impl Read for FileDescriptor { fn read(&mut self, buf: &mut [u8]) -> io::Result { let file_descriptor: libc::c_int = self.0; - let count = unsafe { - libc::read(file_descriptor, buf.as_mut_ptr() as *mut libc::c_void, 1) - }; + let count = + unsafe { libc::read(file_descriptor, buf.as_mut_ptr() as *mut libc::c_void, 1) }; if count < 0 { Err(Error::new(ErrorKind::Other, "read error")) - } - else { + } else { Ok(count as usize) } } -} \ No newline at end of file +} diff --git a/src/common/mod.rs b/src/common/mod.rs index 7109e6287..63a6bd39f 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -1,6 +1,6 @@ pub mod mmap; pub mod slice; +mod file_descriptor; #[cfg(test)] pub mod stdio; -mod file_descriptor; \ No newline at end of file diff --git a/src/common/stdio.rs b/src/common/stdio.rs index 2625136bc..8e26c67ce 100644 --- a/src/common/stdio.rs +++ b/src/common/stdio.rs @@ -1,7 +1,7 @@ +use crate::common::file_descriptor::FileDescriptor; use libc; use std::io::BufReader; use std::io::Read; -use crate::common::file_descriptor::FileDescriptor; // A struct to hold the references to the base stdout and the captured one pub struct StdioCapturer { @@ -21,7 +21,10 @@ impl StdioCapturer { #[cfg(not(target_os = "windows"))] assert_eq!(unsafe { libc::pipe(fds.as_mut_ptr()) }, 0); #[cfg(target_os = "windows")] - assert_eq!(unsafe { libc::pipe(fds.as_mut_ptr(), 1000, libc::O_TEXT) }, 0); + assert_eq!( + unsafe { libc::pipe(fds.as_mut_ptr(), 1000, libc::O_TEXT) }, + 0 + ); (fds[0], fds[1]) }