Skip to content

Commit 495ecba

Browse files
committed
rust: various cleanups and move to Rust 2021
1 parent 2402a30 commit 495ecba

File tree

4 files changed

+33
-27
lines changed

4 files changed

+33
-27
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
keywords = ["windows", "winapi", "util", "win"]
1111
license = "Unlicense/MIT"
1212
categories = ["os::windows-apis", "external-ffi-bindings"]
13-
edition = "2018"
13+
edition = "2021"
1414

1515
[target.'cfg(windows)'.dependencies.winapi]
1616
version = "0.3"

src/console.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
use std::io;
2-
use std::mem;
3-
4-
use winapi::shared::minwindef::WORD;
5-
use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode};
6-
use winapi::um::wincon::{
7-
self, GetConsoleScreenBufferInfo, SetConsoleTextAttribute,
8-
CONSOLE_SCREEN_BUFFER_INFO, FOREGROUND_BLUE as FG_BLUE,
9-
FOREGROUND_GREEN as FG_GREEN, FOREGROUND_INTENSITY as FG_INTENSITY,
10-
FOREGROUND_RED as FG_RED,
1+
use std::{io, mem};
2+
3+
use winapi::{
4+
shared::minwindef::WORD,
5+
um::{
6+
consoleapi::{GetConsoleMode, SetConsoleMode},
7+
wincon::{
8+
self, GetConsoleScreenBufferInfo, SetConsoleTextAttribute,
9+
CONSOLE_SCREEN_BUFFER_INFO, FOREGROUND_BLUE as FG_BLUE,
10+
FOREGROUND_GREEN as FG_GREEN,
11+
FOREGROUND_INTENSITY as FG_INTENSITY, FOREGROUND_RED as FG_RED,
12+
},
13+
},
1114
};
1215

1316
use crate::{AsHandleRef, HandleRef};
@@ -208,7 +211,7 @@ impl Console {
208211
let h = kind.handle();
209212
let info = screen_buffer_info(&h)?;
210213
let attr = TextAttributes::from_word(info.attributes());
211-
Ok(Console { kind: kind, start_attr: attr, cur_attr: attr })
214+
Ok(Console { kind, start_attr: attr, cur_attr: attr })
212215
}
213216

214217
/// Create a new Console to stdout.

src/file.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
use std::io;
2-
use std::mem;
3-
4-
use winapi::shared::minwindef::FILETIME;
5-
use winapi::shared::winerror::NO_ERROR;
6-
use winapi::um::errhandlingapi::GetLastError;
7-
use winapi::um::fileapi::{
8-
GetFileInformationByHandle, GetFileType, BY_HANDLE_FILE_INFORMATION,
1+
use std::{io, mem};
2+
3+
use winapi::{
4+
shared::{minwindef::FILETIME, winerror::NO_ERROR},
5+
um::{
6+
errhandlingapi::GetLastError,
7+
fileapi::{
8+
GetFileInformationByHandle, GetFileType,
9+
BY_HANDLE_FILE_INFORMATION,
10+
},
11+
winnt,
12+
},
913
};
10-
use winapi::um::winnt;
1114

1215
use crate::AsHandleRef;
1316

src/win.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::fs::File;
2-
use std::io;
3-
use std::os::windows::io::{
4-
AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle,
1+
use std::{
2+
fs::File,
3+
io,
4+
os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle},
5+
path::Path,
6+
process,
57
};
6-
use std::path::Path;
7-
use std::process;
88

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

0 commit comments

Comments
 (0)