From 87513b0d9dd7bbf48504b44054f9aae5f6b6940d Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 15 Oct 2025 13:37:48 +0100 Subject: [PATCH 1/5] Let RawOsError be a pub type --- src/error.rs | 7 +++++-- src/lib.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/error.rs b/src/error.rs index 284533d10..123f28071 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,11 +9,14 @@ cfg_if::cfg_if!( if #[cfg(target_os = "uefi")] { // See the UEFI spec for more information: // https://uefi.org/specs/UEFI/2.10/Apx_D_Status_Codes.html - type RawOsError = usize; + pub type RawOsError = usize; type NonZeroRawOsError = core::num::NonZeroUsize; const UEFI_ERROR_FLAG: RawOsError = 1 << (RawOsError::BITS - 1); } else { - type RawOsError = i32; + /// Raw error code + /// + /// This type is platform-dependent. + pub type RawOsError = i32; type NonZeroRawOsError = core::num::NonZeroI32; } ); diff --git a/src/lib.rs b/src/lib.rs index adb7e5b7e..c98ea19dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,7 +39,7 @@ mod util; #[cfg(feature = "std")] mod error_std_impls; -pub use crate::error::Error; +pub use crate::error::{Error, RawOsError}; /// Fill `dest` with random bytes from the system's preferred random number source. /// From 93632b3333264e6447ec5ca546c0931b64da0c6b Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 15 Oct 2025 13:41:53 +0100 Subject: [PATCH 2/5] Update CHANGELOG --- CHANGELOG.md | 8 ++++++++ src/error.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71f9c7ce8..aa515444c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added +- `RawOsError` type alias [#739] + +[#739]: https://github.com/rust-random/getrandom/pull/739 + ## [0.3.4] - 2025-10-14 ### Major change to `wasm_js` backend @@ -631,6 +638,7 @@ Publish initial implementation. ## [0.0.0] - 2019-01-19 Publish an empty template library. +[Unreleased]: https://github.com/rust-random/getrandom/compare/v0.3.4...master [0.3.4]: https://github.com/rust-random/getrandom/compare/v0.3.3...v0.3.4 [0.3.3]: https://github.com/rust-random/getrandom/compare/v0.3.2...v0.3.3 [0.3.2]: https://github.com/rust-random/getrandom/compare/v0.3.1...v0.3.2 diff --git a/src/error.rs b/src/error.rs index 123f28071..5ae6f1e8c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -7,6 +7,7 @@ use core::fmt; // https://doc.rust-lang.org/std/io/type.RawOsError.html) cfg_if::cfg_if!( if #[cfg(target_os = "uefi")] { + /// Raw error code // See the UEFI spec for more information: // https://uefi.org/specs/UEFI/2.10/Apx_D_Status_Codes.html pub type RawOsError = usize; From 85884848cc7d3436e5d306ce02997989919073ab Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Wed, 15 Oct 2025 16:12:46 +0300 Subject: [PATCH 3/5] Tweak docs --- src/error.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/error.rs b/src/error.rs index 5ae6f1e8c..c5722a49f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,20 +3,23 @@ extern crate std; use core::fmt; -// This private alias mirrors `std::io::RawOsError`: -// https://doc.rust-lang.org/std/io/type.RawOsError.html) cfg_if::cfg_if!( if #[cfg(target_os = "uefi")] { - /// Raw error code // See the UEFI spec for more information: // https://uefi.org/specs/UEFI/2.10/Apx_D_Status_Codes.html + + /// Raw error code. + /// + /// This alias mirrors unstable `std::io::RawOsError`: + /// https://doc.rust-lang.org/std/io/type.RawOsError.html pub type RawOsError = usize; type NonZeroRawOsError = core::num::NonZeroUsize; const UEFI_ERROR_FLAG: RawOsError = 1 << (RawOsError::BITS - 1); } else { - /// Raw error code + /// Raw error code. /// - /// This type is platform-dependent. + /// This alias mirrors unstable `std::io::RawOsError`: + /// https://doc.rust-lang.org/std/io/type.RawOsError.html pub type RawOsError = i32; type NonZeroRawOsError = core::num::NonZeroI32; } From 04311caf808e2a4c4af3e1a840d5faa80cad30fe Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Wed, 15 Oct 2025 16:15:42 +0300 Subject: [PATCH 4/5] fix warning --- src/error.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/error.rs b/src/error.rs index c5722a49f..a81f384fa 100644 --- a/src/error.rs +++ b/src/error.rs @@ -11,7 +11,7 @@ cfg_if::cfg_if!( /// Raw error code. /// /// This alias mirrors unstable `std::io::RawOsError`: - /// https://doc.rust-lang.org/std/io/type.RawOsError.html + /// pub type RawOsError = usize; type NonZeroRawOsError = core::num::NonZeroUsize; const UEFI_ERROR_FLAG: RawOsError = 1 << (RawOsError::BITS - 1); @@ -19,7 +19,7 @@ cfg_if::cfg_if!( /// Raw error code. /// /// This alias mirrors unstable `std::io::RawOsError`: - /// https://doc.rust-lang.org/std/io/type.RawOsError.html + /// pub type RawOsError = i32; type NonZeroRawOsError = core::num::NonZeroI32; } From 7597262dff1be19bda7364e8f7eca0f0859b640e Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Wed, 15 Oct 2025 16:22:57 +0300 Subject: [PATCH 5/5] tweak docs --- src/error.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/error.rs b/src/error.rs index a81f384fa..99a29aa3d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -10,16 +10,18 @@ cfg_if::cfg_if!( /// Raw error code. /// - /// This alias mirrors unstable `std::io::RawOsError`: - /// + /// This alias mirrors unstable [`std::io::RawOsError`]. + /// + /// [`std::io::RawOsError`]: https://doc.rust-lang.org/std/io/type.RawOsError.html pub type RawOsError = usize; type NonZeroRawOsError = core::num::NonZeroUsize; const UEFI_ERROR_FLAG: RawOsError = 1 << (RawOsError::BITS - 1); } else { /// Raw error code. /// - /// This alias mirrors unstable `std::io::RawOsError`: - /// + /// This alias mirrors unstable [`std::io::RawOsError`]. + /// + /// [`std::io::RawOsError`]: https://doc.rust-lang.org/std/io/type.RawOsError.html pub type RawOsError = i32; type NonZeroRawOsError = core::num::NonZeroI32; }