Skip to content

Commit 87a535e

Browse files
Shifted to crate fmt from num
1 parent 8860091 commit 87a535e

File tree

5 files changed

+243
-301
lines changed

5 files changed

+243
-301
lines changed

library/core/src/fmt/int_format.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::mem::MaybeUninit;
2+
3+
/// 41 is chosen as the buffer length, as it is larger
4+
/// than that required to accommodate i128::MIN
5+
/// (39 decimal digits, 1 for negative sign).
6+
const BUF_SIZE: usize = 41;
7+
8+
/// A minimal buffer implementation containing elements of type
9+
/// `MaybeUninit<u8>`.
10+
#[unstable(feature = "int_format_into", issue = "138215")]
11+
#[derive(Debug)]
12+
pub struct NumBuffer {
13+
/// An array of elements of type `MaybeUninit<u8>`.
14+
pub contents: [MaybeUninit<u8>; BUF_SIZE],
15+
}
16+
17+
#[unstable(feature = "int_format_into", issue = "138215")]
18+
impl NumBuffer {
19+
/// Initializes `contents` as an uninitialized array of `MaybeUninit<u8>`.
20+
#[unstable(feature = "int_format_into", issue = "138215")]
21+
pub fn new() -> Self {
22+
NumBuffer { contents: [MaybeUninit::<u8>::uninit(); BUF_SIZE] }
23+
}
24+
}

library/core/src/fmt/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{iter, mem, result, str};
1212
mod builders;
1313
#[cfg(not(no_fp_fmt_parse))]
1414
mod float;
15+
mod int_format;
1516
#[cfg(no_fp_fmt_parse)]
1617
mod nofloat;
1718
mod num;
@@ -46,6 +47,9 @@ impl From<rt::Alignment> for Option<Alignment> {
4647
}
4748
}
4849

50+
#[unstable(feature = "int_format_into", issue = "138215")]
51+
pub use int_format::NumBuffer;
52+
4953
#[stable(feature = "debug_builders", since = "1.2.0")]
5054
pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
5155
#[unstable(feature = "debug_closure_helpers", issue = "117729")]

0 commit comments

Comments
 (0)