Skip to content

Commit f6a7b79

Browse files
authored
Merge pull request #239 from epage/ci
fix(wincon): Restore MSRV
2 parents d2ff8f2 + 92fe1b2 commit f6a7b79

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

.github/workflows/ci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ jobs:
5454
run: cargo hack test --feature-powerset --workspace
5555
msrv:
5656
name: "Check MSRV"
57-
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
os: ["ubuntu-latest", "windows-latest"]
60+
runs-on: ${{ matrix.os }}
5861
steps:
5962
- name: Checkout repository
6063
uses: actions/checkout@v4

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/anstream/src/wincon.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ where
4141
S: anstyle_wincon::WinconStream,
4242
S: IsTerminal,
4343
{
44+
/// Returns `true` if the descriptor/handle refers to a terminal/tty.
4445
#[inline]
4546
pub fn is_terminal(&self) -> bool {
4647
self.raw.is_terminal()

crates/anstyle-query/src/windows.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod windows_console {
1111

1212
fn enable_vt(handle: RawHandle) -> std::io::Result<()> {
1313
unsafe {
14-
let handle: HANDLE = std::mem::transmute(handle);
14+
let handle: HANDLE = handle as HANDLE;
1515
if handle.is_null() {
1616
return Err(std::io::Error::new(
1717
std::io::ErrorKind::BrokenPipe,
@@ -33,7 +33,7 @@ mod windows_console {
3333
}
3434
}
3535

36-
pub fn enable_virtual_terminal_processing() -> std::io::Result<()> {
36+
pub(crate) fn enable_virtual_terminal_processing() -> std::io::Result<()> {
3737
let stdout = std::io::stdout();
3838
let stdout_handle = stdout.as_raw_handle();
3939
let stderr = std::io::stderr();
@@ -72,7 +72,7 @@ pub fn enable_ansi_colors() -> Option<bool> {
7272
windows_console::enable_ansi_colors()
7373
}
7474

75-
/// Raw ENABLE_VIRTUAL_TERMINAL_PROCESSING on stdout/stderr
75+
/// Raw `ENABLE_VIRTUAL_TERMINAL_PROCESSING` on stdout/stderr
7676
#[cfg(windows)]
7777
pub fn enable_virtual_terminal_processing() -> std::io::Result<()> {
7878
windows_console::enable_virtual_terminal_processing()

crates/anstyle-wincon/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ lexopt = "0.3.0"
3333

3434
[target.'cfg(windows)'.dependencies]
3535
windows-sys = { version = "0.59.0", features = ["Win32_System_Console", "Win32_Foundation"] }
36+
once_cell = "1.20.2"
3637

3738
[lints]
3839
workspace = true

crates/anstyle-wincon/examples/set-wincon.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ fn main() -> Result<(), lexopt::Error> {
1818
let fg = args.fg.and_then(|c| c.into_ansi());
1919
let bg = args.bg.and_then(|c| c.into_ansi());
2020

21-
let _ = stdout.write_colored(fg, bg, "".as_bytes());
21+
let _ = stdout.write_colored(fg, bg, b"");
2222

23+
#[allow(clippy::mem_forget)]
2324
std::mem::forget(stdout);
2425

2526
Ok(())

crates/anstyle-wincon/src/windows.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,16 @@ type StdioColorInnerResult = Result<(anstyle::AnsiColor, anstyle::AnsiColor), in
88

99
/// Cached [`get_colors`] call for [`std::io::stdout`]
1010
pub fn stdout_initial_colors() -> StdioColorResult {
11-
static INITIAL: std::sync::OnceLock<StdioColorInnerResult> = std::sync::OnceLock::new();
12-
INITIAL
13-
.get_or_init(|| get_colors_(&std::io::stdout()))
14-
.clone()
15-
.map_err(Into::into)
11+
static INITIAL: once_cell::sync::OnceCell<StdioColorInnerResult> =
12+
once_cell::sync::OnceCell::new();
13+
(*INITIAL.get_or_init(|| get_colors_(&std::io::stdout()))).map_err(Into::into)
1614
}
1715

1816
/// Cached [`get_colors`] call for [`std::io::stderr`]
1917
pub fn stderr_initial_colors() -> StdioColorResult {
20-
static INITIAL: std::sync::OnceLock<StdioColorInnerResult> = std::sync::OnceLock::new();
21-
INITIAL
22-
.get_or_init(|| get_colors_(&std::io::stderr()))
23-
.clone()
24-
.map_err(Into::into)
18+
static INITIAL: once_cell::sync::OnceCell<StdioColorInnerResult> =
19+
once_cell::sync::OnceCell::new();
20+
(*INITIAL.get_or_init(|| get_colors_(&std::io::stderr()))).map_err(Into::into)
2521
}
2622

2723
/// Apply colors to future writes
@@ -129,7 +125,7 @@ mod inner {
129125
handle: RawHandle,
130126
) -> Result<CONSOLE_SCREEN_BUFFER_INFO, IoError> {
131127
unsafe {
132-
let handle: HANDLE = std::mem::transmute(handle);
128+
let handle: HANDLE = handle as HANDLE;
133129
if handle.is_null() {
134130
return Err(IoError::BrokenPipe);
135131
}
@@ -150,7 +146,7 @@ mod inner {
150146
attributes: CONSOLE_CHARACTER_ATTRIBUTES,
151147
) -> Result<(), IoError> {
152148
unsafe {
153-
let handle: HANDLE = std::mem::transmute(handle);
149+
let handle: HANDLE = handle as HANDLE;
154150
if handle.is_null() {
155151
return Err(IoError::BrokenPipe);
156152
}
@@ -258,7 +254,7 @@ mod inner {
258254
for expected in COLORS {
259255
let nibble = to_nibble(expected);
260256
let actual = from_nibble(nibble);
261-
assert_eq!(expected, actual, "Intermediate: {}", nibble);
257+
assert_eq!(expected, actual, "Intermediate: {nibble}");
262258
}
263259
}
264260
}

0 commit comments

Comments
 (0)