@@ -131,6 +131,7 @@ impl<R: BlockRngCore + fmt::Debug> fmt::Debug for BlockRng<R> {
131131impl < R : BlockRngCore > BlockRng < R > {
132132 /// Create a new `BlockRng` from an existing RNG implementing
133133 /// `BlockRngCore`. Results will be generated on first use.
134+ #[ inline]
134135 pub fn new ( core : R ) -> BlockRng < R > {
135136 let results_empty = R :: Results :: default ( ) ;
136137 BlockRng {
@@ -145,18 +146,21 @@ impl<R: BlockRngCore> BlockRng<R> {
145146 /// If this is equal to or larger than the size of the result buffer then
146147 /// the buffer is "empty" and `generate()` must be called to produce new
147148 /// results.
149+ #[ inline( always) ]
148150 pub fn index ( & self ) -> usize {
149151 self . index
150152 }
151153
152154 /// Reset the number of available results.
153155 /// This will force a new set of results to be generated on next use.
156+ #[ inline]
154157 pub fn reset ( & mut self ) {
155158 self . index = self . results . as_ref ( ) . len ( ) ;
156159 }
157160
158161 /// Generate a new set of results immediately, setting the index to the
159162 /// given value.
163+ #[ inline]
160164 pub fn generate_and_set ( & mut self , index : usize ) {
161165 assert ! ( index < self . results. as_ref( ) . len( ) ) ;
162166 self . core . generate ( & mut self . results ) ;
@@ -167,7 +171,7 @@ impl<R: BlockRngCore> BlockRng<R> {
167171impl < R : BlockRngCore < Item =u32 > > RngCore for BlockRng < R >
168172where <R as BlockRngCore >:: Results : AsRef < [ u32 ] > + AsMut < [ u32 ] >
169173{
170- #[ inline( always ) ]
174+ #[ inline]
171175 fn next_u32 ( & mut self ) -> u32 {
172176 if self . index >= self . results . as_ref ( ) . len ( ) {
173177 self . generate_and_set ( 0 ) ;
@@ -178,7 +182,7 @@ where <R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>
178182 value
179183 }
180184
181- #[ inline( always ) ]
185+ #[ inline]
182186 fn next_u64 ( & mut self ) -> u64 {
183187 let read_u64 = |results : & [ u32 ] , index| {
184188 if cfg ! ( any( target_endian = "little" ) ) {
@@ -210,6 +214,7 @@ where <R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>
210214 }
211215 }
212216
217+ #[ inline]
213218 fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
214219 let mut read_len = 0 ;
215220 while read_len < dest. len ( ) {
@@ -225,23 +230,26 @@ where <R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>
225230 }
226231 }
227232
233+ #[ inline( always) ]
228234 fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
229- self . fill_bytes ( dest) ;
230- Ok ( ( ) )
235+ Ok ( self . fill_bytes ( dest) )
231236 }
232237}
233238
234239impl < R : BlockRngCore + SeedableRng > SeedableRng for BlockRng < R > {
235240 type Seed = R :: Seed ;
236241
242+ #[ inline( always) ]
237243 fn from_seed ( seed : Self :: Seed ) -> Self {
238244 Self :: new ( R :: from_seed ( seed) )
239245 }
240246
247+ #[ inline( always) ]
241248 fn seed_from_u64 ( seed : u64 ) -> Self {
242249 Self :: new ( R :: seed_from_u64 ( seed) )
243250 }
244251
252+ #[ inline( always) ]
245253 fn from_rng < S : RngCore > ( rng : S ) -> Result < Self , Error > {
246254 Ok ( Self :: new ( R :: from_rng ( rng) ?) )
247255 }
@@ -296,6 +304,7 @@ impl<R: BlockRngCore + fmt::Debug> fmt::Debug for BlockRng64<R> {
296304impl < R : BlockRngCore > BlockRng64 < R > {
297305 /// Create a new `BlockRng` from an existing RNG implementing
298306 /// `BlockRngCore`. Results will be generated on first use.
307+ #[ inline]
299308 pub fn new ( core : R ) -> BlockRng64 < R > {
300309 let results_empty = R :: Results :: default ( ) ;
301310 BlockRng64 {
@@ -311,19 +320,22 @@ impl<R: BlockRngCore> BlockRng64<R> {
311320 /// If this is equal to or larger than the size of the result buffer then
312321 /// the buffer is "empty" and `generate()` must be called to produce new
313322 /// results.
323+ #[ inline( always) ]
314324 pub fn index ( & self ) -> usize {
315325 self . index
316326 }
317327
318328 /// Reset the number of available results.
319329 /// This will force a new set of results to be generated on next use.
330+ #[ inline]
320331 pub fn reset ( & mut self ) {
321332 self . index = self . results . as_ref ( ) . len ( ) ;
322333 self . half_used = false ;
323334 }
324335
325336 /// Generate a new set of results immediately, setting the index to the
326337 /// given value.
338+ #[ inline]
327339 pub fn generate_and_set ( & mut self , index : usize ) {
328340 assert ! ( index < self . results. as_ref( ) . len( ) ) ;
329341 self . core . generate ( & mut self . results ) ;
@@ -335,7 +347,7 @@ impl<R: BlockRngCore> BlockRng64<R> {
335347impl < R : BlockRngCore < Item =u64 > > RngCore for BlockRng64 < R >
336348where <R as BlockRngCore >:: Results : AsRef < [ u64 ] > + AsMut < [ u64 ] >
337349{
338- #[ inline( always ) ]
350+ #[ inline]
339351 fn next_u32 ( & mut self ) -> u32 {
340352 let mut index = self . index * 2 - self . half_used as usize ;
341353 if index >= self . results . as_ref ( ) . len ( ) * 2 {
@@ -361,7 +373,7 @@ where <R as BlockRngCore>::Results: AsRef<[u64]> + AsMut<[u64]>
361373 }
362374 }
363375
364- #[ inline( always ) ]
376+ #[ inline]
365377 fn next_u64 ( & mut self ) -> u64 {
366378 if self . index >= self . results . as_ref ( ) . len ( ) {
367379 self . core . generate ( & mut self . results ) ;
@@ -374,6 +386,7 @@ where <R as BlockRngCore>::Results: AsRef<[u64]> + AsMut<[u64]>
374386 value
375387 }
376388
389+ #[ inline]
377390 fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
378391 let mut read_len = 0 ;
379392 self . half_used = false ;
@@ -392,6 +405,7 @@ where <R as BlockRngCore>::Results: AsRef<[u64]> + AsMut<[u64]>
392405 }
393406 }
394407
408+ #[ inline( always) ]
395409 fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
396410 Ok ( self . fill_bytes ( dest) )
397411 }
@@ -400,14 +414,17 @@ where <R as BlockRngCore>::Results: AsRef<[u64]> + AsMut<[u64]>
400414impl < R : BlockRngCore + SeedableRng > SeedableRng for BlockRng64 < R > {
401415 type Seed = R :: Seed ;
402416
417+ #[ inline( always) ]
403418 fn from_seed ( seed : Self :: Seed ) -> Self {
404419 Self :: new ( R :: from_seed ( seed) )
405420 }
406421
422+ #[ inline( always) ]
407423 fn seed_from_u64 ( seed : u64 ) -> Self {
408424 Self :: new ( R :: seed_from_u64 ( seed) )
409425 }
410426
427+ #[ inline( always) ]
411428 fn from_rng < S : RngCore > ( rng : S ) -> Result < Self , Error > {
412429 Ok ( Self :: new ( R :: from_rng ( rng) ?) )
413430 }
0 commit comments