Skip to content

Commit a87115c

Browse files
committed
Convert ilog(10) to ilog10()
1 parent 255aa22 commit a87115c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

library/alloc/src/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,7 +2841,7 @@ macro_rules! impl_to_string {
28412841
impl SpecToString for $signed {
28422842
#[inline]
28432843
fn spec_to_string(&self) -> String {
2844-
const SIZE: usize = $signed::MAX.ilog(10) as usize + 1;
2844+
const SIZE: usize = $signed::MAX.ilog10() as usize + 1;
28452845
let mut buf = [core::mem::MaybeUninit::<u8>::uninit(); SIZE];
28462846
// Only difference between signed and unsigned are these 8 lines.
28472847
let mut out;
@@ -2861,7 +2861,7 @@ macro_rules! impl_to_string {
28612861
impl SpecToString for $unsigned {
28622862
#[inline]
28632863
fn spec_to_string(&self) -> String {
2864-
const SIZE: usize = $unsigned::MAX.ilog(10) as usize + 1;
2864+
const SIZE: usize = $unsigned::MAX.ilog10() as usize + 1;
28652865
let mut buf = [core::mem::MaybeUninit::<u8>::uninit(); SIZE];
28662866

28672867
self._fmt(&mut buf).to_string()

library/core/src/fmt/num.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ macro_rules! impl_Display {
208208
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
209209
#[cfg(not(feature = "optimize_for_size"))]
210210
{
211-
const MAX_DEC_N: usize = $unsigned::MAX.ilog(10) as usize + 1;
211+
const MAX_DEC_N: usize = $unsigned::MAX.ilog10() as usize + 1;
212212
// Buffer decimals for $unsigned with right alignment.
213213
let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];
214214

@@ -226,7 +226,7 @@ macro_rules! impl_Display {
226226
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
227227
#[cfg(not(feature = "optimize_for_size"))]
228228
{
229-
const MAX_DEC_N: usize = $unsigned::MAX.ilog(10) as usize + 1;
229+
const MAX_DEC_N: usize = $unsigned::MAX.ilog10() as usize + 1;
230230
// Buffer decimals for $unsigned with right alignment.
231231
let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];
232232

@@ -323,7 +323,7 @@ macro_rules! impl_Display {
323323

324324
#[cfg(feature = "optimize_for_size")]
325325
fn $gen_name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result {
326-
const MAX_DEC_N: usize = $u::MAX.ilog(10) as usize + 1;
326+
const MAX_DEC_N: usize = $u::MAX.ilog10() as usize + 1;
327327
let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];
328328
let mut curr = MAX_DEC_N;
329329
let buf_ptr = MaybeUninit::slice_as_mut_ptr(&mut buf);
@@ -589,7 +589,7 @@ fn fmt_u128(n: u128, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::R
589589
}
590590

591591
// U128::MAX has 39 significant-decimals.
592-
const MAX_DEC_N: usize = u128::MAX.ilog(10) as usize + 1;
592+
const MAX_DEC_N: usize = u128::MAX.ilog10() as usize + 1;
593593
// Buffer decimals with right alignment.
594594
let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];
595595

src/librustdoc/html/sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ pub(crate) fn print_src(
353353
);
354354
Ok(())
355355
});
356-
let max_nb_digits = if lines > 0 { lines.ilog(10) + 1 } else { 1 };
356+
let max_nb_digits = if lines > 0 { lines.ilog10() + 1 } else { 1 };
357357
match source_context {
358358
SourceContext::Standalone { file_path } => Source {
359359
code_html: code,

0 commit comments

Comments
 (0)