diff --git a/rand_core/CHANGELOG.md b/rand_core/CHANGELOG.md index 84c40cf9aa..15a16704d8 100644 --- a/rand_core/CHANGELOG.md +++ b/rand_core/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### API changes - Relax `Sized` bound on impls of `SeedableRng` (#1641) +- Fix `OsError::raw_os_error` on UEFI targets by returning `Option` (#1665) - Move `rand_core::impls::*` to `rand_core::le` module (#1667) - Use Edition 2024 and MSRV 1.85 (#1668) - Remove fn `TryRngCore::read_adapter(..) -> RngReadAdapter` (replaced with `rand::RngReader`) (#1669) diff --git a/rand_core/src/os.rs b/rand_core/src/os.rs index 49111632d9..dc4125c960 100644 --- a/rand_core/src/os.rs +++ b/rand_core/src/os.rs @@ -66,6 +66,14 @@ impl std::error::Error for OsError { } } +// If [`RawOsError`](https://doc.rust-lang.org/std/io/type.RawOsError.html) is stablized, we can use it. + +#[cfg(not(target_os = "uefi"))] +type RawOsError = i32; + +#[cfg(target_os = "uefi")] +type RawOsError = usize; + impl OsError { /// Extract the raw OS error code (if this error came from the OS) /// @@ -75,7 +83,7 @@ impl OsError { /// /// [1]: https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error #[inline] - pub fn raw_os_error(self) -> Option { + pub fn raw_os_error(self) -> Option { self.0.raw_os_error() } }