From 36f0a5efe231fea567a202fd699f37659f5d8eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Fri, 27 Sep 2024 06:58:45 +0300 Subject: [PATCH] Add #[inline] attributes --- rand_core/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rand_core/src/lib.rs b/rand_core/src/lib.rs index 3f670d1c15..38ec96ece0 100644 --- a/rand_core/src/lib.rs +++ b/rand_core/src/lib.rs @@ -163,12 +163,17 @@ impl RngCore for T where T::Target: RngCore, { + #[inline] fn next_u32(&mut self) -> u32 { self.deref_mut().next_u32() } + + #[inline] fn next_u64(&mut self) -> u64 { self.deref_mut().next_u64() } + + #[inline] fn fill_bytes(&mut self, dst: &mut [u8]) { self.deref_mut().fill_bytes(dst); } @@ -283,14 +288,17 @@ impl TryCryptoRng for R {} pub struct UnwrapErr(pub R); impl RngCore for UnwrapErr { + #[inline] fn next_u32(&mut self) -> u32 { self.0.try_next_u32().unwrap() } + #[inline] fn next_u64(&mut self) -> u64 { self.0.try_next_u64().unwrap() } + #[inline] fn fill_bytes(&mut self, dst: &mut [u8]) { self.0.try_fill_bytes(dst).unwrap() } @@ -530,6 +538,7 @@ pub struct RngReadAdapter<'a, R: TryRngCore + ?Sized> { #[cfg(feature = "std")] impl std::io::Read for RngReadAdapter<'_, R> { + #[inline] fn read(&mut self, buf: &mut [u8]) -> Result { self.inner.try_fill_bytes(buf).map_err(|err| { std::io::Error::new(std::io::ErrorKind::Other, std::format!("RNG error: {err}"))