Skip to content

Commit

Permalink
rust: various cleanups and move to Rust 2021
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Sep 20, 2023
1 parent 2402a30 commit 495ecba
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
keywords = ["windows", "winapi", "util", "win"]
license = "Unlicense/MIT"
categories = ["os::windows-apis", "external-ffi-bindings"]
edition = "2018"
edition = "2021"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3"
Expand Down
25 changes: 14 additions & 11 deletions src/console.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use std::io;
use std::mem;

use winapi::shared::minwindef::WORD;
use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode};
use winapi::um::wincon::{
self, GetConsoleScreenBufferInfo, SetConsoleTextAttribute,
CONSOLE_SCREEN_BUFFER_INFO, FOREGROUND_BLUE as FG_BLUE,
FOREGROUND_GREEN as FG_GREEN, FOREGROUND_INTENSITY as FG_INTENSITY,
FOREGROUND_RED as FG_RED,
use std::{io, mem};

use winapi::{
shared::minwindef::WORD,
um::{
consoleapi::{GetConsoleMode, SetConsoleMode},
wincon::{
self, GetConsoleScreenBufferInfo, SetConsoleTextAttribute,
CONSOLE_SCREEN_BUFFER_INFO, FOREGROUND_BLUE as FG_BLUE,
FOREGROUND_GREEN as FG_GREEN,
FOREGROUND_INTENSITY as FG_INTENSITY, FOREGROUND_RED as FG_RED,
},
},
};

use crate::{AsHandleRef, HandleRef};
Expand Down Expand Up @@ -208,7 +211,7 @@ impl Console {
let h = kind.handle();
let info = screen_buffer_info(&h)?;
let attr = TextAttributes::from_word(info.attributes());
Ok(Console { kind: kind, start_attr: attr, cur_attr: attr })
Ok(Console { kind, start_attr: attr, cur_attr: attr })
}

/// Create a new Console to stdout.
Expand Down
21 changes: 12 additions & 9 deletions src/file.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use std::io;
use std::mem;

use winapi::shared::minwindef::FILETIME;
use winapi::shared::winerror::NO_ERROR;
use winapi::um::errhandlingapi::GetLastError;
use winapi::um::fileapi::{
GetFileInformationByHandle, GetFileType, BY_HANDLE_FILE_INFORMATION,
use std::{io, mem};

use winapi::{
shared::{minwindef::FILETIME, winerror::NO_ERROR},
um::{
errhandlingapi::GetLastError,
fileapi::{
GetFileInformationByHandle, GetFileType,
BY_HANDLE_FILE_INFORMATION,
},
winnt,
},
};
use winapi::um::winnt;

use crate::AsHandleRef;

Expand Down
12 changes: 6 additions & 6 deletions src/win.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::fs::File;
use std::io;
use std::os::windows::io::{
AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle,
use std::{
fs::File,
io,
os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle},
path::Path,
process,
};
use std::path::Path;
use std::process;

/// A handle represents an owned and valid Windows handle to a file-like
/// object.
Expand Down

0 comments on commit 495ecba

Please sign in to comment.