diff --git a/rustfmt.toml b/rustfmt.toml index d83987d..899a094 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,10 +1,4 @@ -# keep imports tidy -reorder_imported_names = true -reorder_imports = true -reorder_imports_in_group = true -# there is no try! -use_try_shorthand = true -# don't create rustfmt artifacts -write_mode = "Replace" -# reduce wide load -max_width = 80 \ No newline at end of file +# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#fn_args_layout +fn_args_layout = "Vertical" +# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports +merge_imports = true \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 2525658..89b7555 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,8 +51,10 @@ pub fn is(stream: Stream) -> bool { /// returns true if this is a tty #[cfg(windows)] pub fn is(stream: Stream) -> bool { - use winapi::um::winbase::{STD_ERROR_HANDLE as STD_ERROR, STD_INPUT_HANDLE as STD_INPUT, - STD_OUTPUT_HANDLE as STD_OUTPUT}; + use winapi::um::winbase::{ + STD_ERROR_HANDLE as STD_ERROR, STD_INPUT_HANDLE as STD_INPUT, + STD_OUTPUT_HANDLE as STD_OUTPUT, + }; let (fd, others) = match stream { Stream::Stdin => (STD_INPUT, [STD_ERROR, STD_OUTPUT]), @@ -86,8 +88,7 @@ pub fn isnt(stream: Stream) -> bool { /// Returns true if any of the given fds are on a console. #[cfg(windows)] unsafe fn console_on_any(fds: &[DWORD]) -> bool { - use winapi::um::consoleapi::GetConsoleMode; - use winapi::um::processenv::GetStdHandle; + use winapi::um::{consoleapi::GetConsoleMode, processenv::GetStdHandle}; for &fd in fds { let mut out = 0; @@ -102,15 +103,16 @@ unsafe fn console_on_any(fds: &[DWORD]) -> bool { /// Returns true if there is an MSYS tty on the given handle. #[cfg(windows)] unsafe fn msys_tty_on(fd: DWORD) -> bool { - use std::mem; - use std::slice; + use std::{mem, slice}; - use winapi::ctypes::c_void; - use winapi::um::winbase::GetFileInformationByHandleEx; - use winapi::um::fileapi::FILE_NAME_INFO; - use winapi::um::minwinbase::FileNameInfo; - use winapi::um::processenv::GetStdHandle; - use winapi::shared::minwindef::MAX_PATH; + use winapi::{ + ctypes::c_void, + shared::minwindef::MAX_PATH, + um::{ + fileapi::FILE_NAME_INFO, minwinbase::FileNameInfo, processenv::GetStdHandle, + winbase::GetFileInformationByHandleEx, + }, + }; let size = mem::size_of::(); let mut name_info_bytes = vec![0u8; size + MAX_PATH * mem::size_of::()]; @@ -146,7 +148,7 @@ pub fn is(_stream: Stream) -> bool { #[cfg(test)] mod tests { - use super::{Stream, is}; + use super::{is, Stream}; #[test] #[cfg(windows)]