mirror of
https://github.com/openharmony/third_party_rust_atty.git
synced 2026-07-01 09:25:06 -04:00
update rustfmt settings
This commit is contained in:
+4
-10
@@ -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
|
||||
# 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
|
||||
+15
-13
@@ -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::<FILE_NAME_INFO>();
|
||||
let mut name_info_bytes = vec![0u8; size + MAX_PATH * mem::size_of::<WCHAR>()];
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user