From efe113ccd1d54616faee38cf269fe6b3858178b8 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Thu, 20 Mar 2025 10:33:56 -0700 Subject: [PATCH] Use `core::ffi::c_int` directly instead of alias Replace the internal `Int` type alias with the now-stable `core::ffi::c_int` type, simplifying code by removing conditional definitions. This cleanup is possible since `core::ffi::c_int` stabilized in Rust 1.64.0, and our current MSRV is 1.76.0. --- src/format/mod.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/format/mod.rs b/src/format/mod.rs index aee6a971..1f866c0d 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -6,6 +6,7 @@ mod utils; mod week; mod write; +use core::ffi::c_int; use core::fmt; use core::num::IntErrorKind; use core::str; @@ -21,13 +22,6 @@ pub(crate) use write::FmtWrite; #[cfg(feature = "std")] pub(crate) use write::IoWrite; -/// Alias to a `c_int`. -#[cfg(feature = "std")] -type Int = std::os::raw::c_int; -/// Fallback alias to a `c_int`. -#[cfg(not(feature = "std"))] -type Int = i32; - /// List of weekday names. const DAYS: [&str; 7] = [ "Sunday", @@ -810,7 +804,7 @@ impl<'t, 'f, T: CheckedTime> TimeFormatter<'t, 'f, T> { .expect("reading ASCII digits should yield a valid UTF-8 slice"); let width = match width_digits.parse::() { - Ok(width) if Int::try_from(width).is_ok() => Some(width), + Ok(width) if c_int::try_from(width).is_ok() => Some(width), Err(err) if *err.kind() == IntErrorKind::Empty => None, _ => return Ok(None), };