Skip to content

Commit a25fec6

Browse files
committed
Rename iterators to U32Digits and U64Digits
1 parent aeb8e30 commit a25fec6

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

src/bigint.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use self::Sign::{Minus, NoSign, Plus};
3131
use crate::big_digit::{self, BigDigit, DoubleBigDigit};
3232
use crate::biguint;
3333
use crate::biguint::to_str_radix_reversed;
34-
use crate::biguint::{BigUint, IntDigits, IterU32Digits, IterU64Digits};
34+
use crate::biguint::{BigUint, IntDigits, U32Digits, U64Digits};
3535
use crate::ParseBigIntError;
3636
#[cfg(has_try_from)]
3737
use crate::TryFromBigIntError;
@@ -3000,7 +3000,7 @@ impl BigInt {
30003000
(self.sign, self.data.to_u64_digits())
30013001
}
30023002

3003-
/// Returns an iterator of `u32` digits representation of the `BigUint` ordered least
3003+
/// Returns an iterator of `u32` digits representation of the `BigInt` ordered least
30043004
/// significant digit first.
30053005
///
30063006
/// # Examples
@@ -3015,11 +3015,11 @@ impl BigInt {
30153015
/// assert_eq!(BigInt::from(112500000000i64).iter_u32_digits().collect::<Vec<u32>>(), vec![830850304, 26]);
30163016
/// ```
30173017
#[inline]
3018-
pub fn iter_u32_digits(&self) -> IterU32Digits<'_> {
3018+
pub fn iter_u32_digits(&self) -> U32Digits<'_> {
30193019
self.data.iter_u32_digits()
30203020
}
30213021

3022-
/// Returns an iterator of `u64` digits representation of the `BigUint` ordered least
3022+
/// Returns an iterator of `u64` digits representation of the `BigInt` ordered least
30233023
/// significant digit first.
30243024
///
30253025
/// # Examples
@@ -3034,7 +3034,7 @@ impl BigInt {
30343034
/// assert_eq!(BigInt::from(112500000000i64).iter_u64_digits().collect::<Vec<u64>>(), vec![112500000000u64]);
30353035
/// ```
30363036
#[inline]
3037-
pub fn iter_u64_digits(&self) -> IterU64Digits<'_> {
3037+
pub fn iter_u64_digits(&self) -> U64Digits<'_> {
30383038
self.data.iter_u64_digits()
30393039
}
30403040

src/biguint.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,9 +2288,9 @@ pub(crate) fn to_str_radix_reversed(u: &BigUint, radix: u32) -> Vec<u8> {
22882288
res
22892289
}
22902290

2291-
/// An iterator of `u32` digits representation of the `BigUint` ordered least
2292-
/// significant digit first.
2293-
pub struct IterU32Digits<'a> {
2291+
/// An iterator of `u32` digits representation of a `BigUint` or `BigInt`,
2292+
/// ordered least significant digit first.
2293+
pub struct U32Digits<'a> {
22942294
#[cfg(u64_digit)]
22952295
data: &'a [u64],
22962296
#[cfg(u64_digit)]
@@ -2302,7 +2302,7 @@ pub struct IterU32Digits<'a> {
23022302
it: core::slice::Iter<'a, u32>,
23032303
}
23042304
#[cfg(u64_digit)]
2305-
impl<'a> IterU32Digits<'a> {
2305+
impl<'a> U32Digits<'a> {
23062306
#[inline]
23072307
fn new(data: &'a [u64]) -> Self {
23082308
let last_hi_is_zero = data
@@ -2312,15 +2312,15 @@ impl<'a> IterU32Digits<'a> {
23122312
last_hi == 0
23132313
})
23142314
.unwrap_or(false);
2315-
IterU32Digits {
2315+
U32Digits {
23162316
data,
23172317
next_is_lo: true,
23182318
last_hi_is_zero,
23192319
}
23202320
}
23212321
}
23222322
#[cfg(u64_digit)]
2323-
impl Iterator for IterU32Digits<'_> {
2323+
impl Iterator for U32Digits<'_> {
23242324
type Item = u32;
23252325
#[inline]
23262326
fn next(&mut self) -> Option<u32> {
@@ -2367,22 +2367,22 @@ impl Iterator for IterU32Digits<'_> {
23672367
}
23682368
}
23692369
#[cfg(u64_digit)]
2370-
impl ExactSizeIterator for IterU32Digits<'_> {
2370+
impl ExactSizeIterator for U32Digits<'_> {
23712371
#[inline]
23722372
fn len(&self) -> usize {
23732373
self.data.len() * 2 - usize::from(self.last_hi_is_zero) - usize::from(!self.next_is_lo)
23742374
}
23752375
}
23762376

23772377
#[cfg(not(u64_digit))]
2378-
impl<'a> IterU32Digits<'a> {
2378+
impl<'a> U32Digits<'a> {
23792379
#[inline]
23802380
fn new(data: &'a [u32]) -> Self {
23812381
Self { it: data.iter() }
23822382
}
23832383
}
23842384
#[cfg(not(u64_digit))]
2385-
impl Iterator for IterU32Digits<'_> {
2385+
impl Iterator for U32Digits<'_> {
23862386
type Item = u32;
23872387
#[inline]
23882388
fn next(&mut self) -> Option<u32> {
@@ -2410,34 +2410,34 @@ impl Iterator for IterU32Digits<'_> {
24102410
}
24112411
}
24122412
#[cfg(not(u64_digit))]
2413-
impl ExactSizeIterator for IterU32Digits<'_> {
2413+
impl ExactSizeIterator for U32Digits<'_> {
24142414
#[inline]
24152415
fn len(&self) -> usize {
24162416
self.it.len()
24172417
}
24182418
}
24192419

2420-
impl FusedIterator for IterU32Digits<'_> {}
2420+
impl FusedIterator for U32Digits<'_> {}
24212421

2422-
/// An iterator of `u64` digits representation of the `BigUint` ordered least
2423-
/// significant digit first.
2424-
pub struct IterU64Digits<'a> {
2422+
/// An iterator of `u64` digits representation of a `BigUint` or `BigInt`,
2423+
/// ordered least significant digit first.
2424+
pub struct U64Digits<'a> {
24252425
#[cfg(not(u64_digit))]
24262426
it: core::slice::Chunks<'a, u32>,
24272427

24282428
#[cfg(u64_digit)]
24292429
it: core::slice::Iter<'a, u64>,
24302430
}
24312431
#[cfg(not(u64_digit))]
2432-
impl<'a> IterU64Digits<'a> {
2432+
impl<'a> U64Digits<'a> {
24332433
#[inline]
24342434
fn new(data: &'a [u32]) -> Self {
2435-
IterU64Digits { it: data.chunks(2) }
2435+
U64Digits { it: data.chunks(2) }
24362436
}
24372437
}
24382438

24392439
#[cfg(not(u64_digit))]
2440-
impl Iterator for IterU64Digits<'_> {
2440+
impl Iterator for U64Digits<'_> {
24412441
type Item = u64;
24422442
#[inline]
24432443
fn next(&mut self) -> Option<u64> {
@@ -2461,22 +2461,22 @@ impl Iterator for IterU64Digits<'_> {
24612461
}
24622462
}
24632463
#[cfg(not(u64_digit))]
2464-
impl ExactSizeIterator for IterU64Digits<'_> {
2464+
impl ExactSizeIterator for U64Digits<'_> {
24652465
#[inline]
24662466
fn len(&self) -> usize {
24672467
self.it.len()
24682468
}
24692469
}
24702470

24712471
#[cfg(u64_digit)]
2472-
impl<'a> IterU64Digits<'a> {
2472+
impl<'a> U64Digits<'a> {
24732473
#[inline]
24742474
fn new(data: &'a [u64]) -> Self {
24752475
Self { it: data.iter() }
24762476
}
24772477
}
24782478
#[cfg(u64_digit)]
2479-
impl Iterator for IterU64Digits<'_> {
2479+
impl Iterator for U64Digits<'_> {
24802480
type Item = u64;
24812481
#[inline]
24822482
fn next(&mut self) -> Option<u64> {
@@ -2504,13 +2504,13 @@ impl Iterator for IterU64Digits<'_> {
25042504
}
25052505
}
25062506
#[cfg(u64_digit)]
2507-
impl ExactSizeIterator for IterU64Digits<'_> {
2507+
impl ExactSizeIterator for U64Digits<'_> {
25082508
#[inline]
25092509
fn len(&self) -> usize {
25102510
self.it.len()
25112511
}
25122512
}
2513-
impl FusedIterator for IterU64Digits<'_> {}
2513+
impl FusedIterator for U64Digits<'_> {}
25142514

25152515
/// Creates and initializes a `BigUint`.
25162516
///
@@ -2809,8 +2809,8 @@ impl BigUint {
28092809
/// assert_eq!(BigUint::from(112500000000u64).iter_u32_digits().collect::<Vec<u32>>(), vec![830850304, 26]);
28102810
/// ```
28112811
#[inline]
2812-
pub fn iter_u32_digits(&self) -> IterU32Digits<'_> {
2813-
IterU32Digits::new(self.data.as_slice())
2812+
pub fn iter_u32_digits(&self) -> U32Digits<'_> {
2813+
U32Digits::new(self.data.as_slice())
28142814
}
28152815

28162816
/// Returns an iterator of `u64` digits representation of the `BigUint` ordered least
@@ -2827,8 +2827,8 @@ impl BigUint {
28272827
/// assert_eq!(BigUint::from(112500000000u64).iter_u64_digits().collect::<Vec<u64>>(), vec![112500000000]);
28282828
/// ```
28292829
#[inline]
2830-
pub fn iter_u64_digits(&self) -> IterU64Digits<'_> {
2831-
IterU64Digits::new(self.data.as_slice())
2830+
pub fn iter_u64_digits(&self) -> U64Digits<'_> {
2831+
U64Digits::new(self.data.as_slice())
28322832
}
28332833

28342834
/// Returns the integer formatted as a string in the given radix.

0 commit comments

Comments
 (0)