diff --git a/src/lib.rs b/src/lib.rs index f32e22c8df..cd42f772cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -726,22 +726,20 @@ pub trait Rng: RngCore + Sized { impl Rng for R {} impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R { - #[inline] + #[inline(always)] fn next_u32(&mut self) -> u32 { (**self).next_u32() } - #[inline] + #[inline(always)] fn next_u64(&mut self) -> u64 { (**self).next_u64() } - #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { (**self).fill_bytes(dest) } - - #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { (**self).try_fill_bytes(dest) } @@ -749,22 +747,20 @@ impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R { #[cfg(any(feature="std", feature="alloc"))] impl RngCore for Box { - #[inline] + #[inline(always)] fn next_u32(&mut self) -> u32 { (**self).next_u32() } - #[inline] + #[inline(always)] fn next_u64(&mut self) -> u64 { (**self).next_u64() } - #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { (**self).fill_bytes(dest) } - - #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { (**self).try_fill_bytes(dest) } @@ -1028,10 +1024,12 @@ pub trait BlockRngCore: Sized { pub struct StdRng(Hc128Rng); impl RngCore for StdRng { + #[inline(always)] fn next_u32(&mut self) -> u32 { self.0.next_u32() } + #[inline(always)] fn next_u64(&mut self) -> u64 { self.0.next_u64() } diff --git a/src/prng/hc128.rs b/src/prng/hc128.rs index a42f3da4fe..9da03c9bd6 100644 --- a/src/prng/hc128.rs +++ b/src/prng/hc128.rs @@ -66,22 +66,20 @@ const SEED_WORDS: usize = 8; // 128 bit key followed by 128 bit iv pub struct Hc128Rng(BlockRng); impl RngCore for Hc128Rng { - #[inline] + #[inline(always)] fn next_u32(&mut self) -> u32 { self.0.next_u32() } - #[inline] + #[inline(always)] fn next_u64(&mut self) -> u64 { self.0.next_u64() } - #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { self.0.fill_bytes(dest) } - #[inline] fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { self.0.try_fill_bytes(dest) } diff --git a/src/reseeding.rs b/src/reseeding.rs index bea6542be2..cb4b450a3a 100644 --- a/src/reseeding.rs +++ b/src/reseeding.rs @@ -93,22 +93,20 @@ where R: BlockRngCore + SeedableRng, } impl + SeedableRng, Rsdr: RngCore> RngCore for ReseedingRng { - #[inline] + #[inline(always)] fn next_u32(&mut self) -> u32 { self.0.next_u32() } - #[inline] + #[inline(always)] fn next_u64(&mut self) -> u64 { self.0.next_u64() } - #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { self.0.fill_bytes(dest) } - #[inline] fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { self.0.try_fill_bytes(dest) } diff --git a/src/thread_rng.rs b/src/thread_rng.rs index b95de87ab2..54a7beae86 100644 --- a/src/thread_rng.rs +++ b/src/thread_rng.rs @@ -78,22 +78,20 @@ pub fn thread_rng() -> ThreadRng { } impl RngCore for ThreadRng { - #[inline] + #[inline(always)] fn next_u32(&mut self) -> u32 { self.rng.borrow_mut().next_u32() } - #[inline] + #[inline(always)] fn next_u64(&mut self) -> u64 { self.rng.borrow_mut().next_u64() } - #[inline] fn fill_bytes(&mut self, bytes: &mut [u8]) { self.rng.borrow_mut().fill_bytes(bytes) } - - #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { self.rng.borrow_mut().try_fill_bytes(dest) }