Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rand_core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>` (#1665)

## [0.9.3] — 2025-02-29
### Other
Expand Down
10 changes: 9 additions & 1 deletion rand_core/src/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
///
Expand All @@ -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<i32> {
pub fn raw_os_error(self) -> Option<RawOsError> {
self.0.raw_os_error()
}
}
Expand Down