11use crate :: mem:: MaybeUninit ;
22
33/// Trait used to describe the maximum number of digits in decimal base of the implemented integer.
4- #[ unstable( feature = "int_format_into " , issue = "138215 " ) ]
4+ #[ unstable( feature = "fmt_internals " , issue = "none " ) ]
55pub trait NumBufferTrait {
66 /// Maximum number of digits in decimal base of the implemented integer.
7+ #[ unstable( feature = "fmt_internals" , issue = "none" ) ]
78 const BUF_SIZE : usize ;
89}
910
1011macro_rules! impl_NumBufferTrait {
1112 ( $( $signed: ident, $unsigned: ident, ) * ) => {
1213 $(
13- #[ unstable ( feature = "int_format_into" , issue = "138215 " ) ]
14+ #[ stable ( feature = "int_format_into" , since = "CURRENT_RUSTC_VERSION " ) ]
1415 impl NumBufferTrait for $signed {
1516 // `+ 2` and not `+ 1` to include the `-` character.
1617 const BUF_SIZE : usize = $signed:: MAX . ilog( 10 ) as usize + 2 ;
1718 }
18- #[ unstable ( feature = "int_format_into" , issue = "138215 " ) ]
19+ #[ stable ( feature = "int_format_into" , since = "CURRENT_RUSTC_VERSION " ) ]
1920 impl NumBufferTrait for $unsigned {
2021 const BUF_SIZE : usize = $unsigned:: MAX . ilog( 10 ) as usize + 1 ;
2122 }
@@ -38,7 +39,6 @@ impl_NumBufferTrait! {
3839/// # Examples
3940///
4041/// ```
41- /// #![feature(int_format_into)]
4242/// use core::fmt::NumBuffer;
4343///
4444/// let mut buf = NumBuffer::new();
@@ -50,33 +50,32 @@ impl_NumBufferTrait! {
5050/// let n2 = -1972i32;
5151/// assert_eq!(n2.format_into(&mut buf), "-1972");
5252/// ```
53- #[ unstable ( feature = "int_format_into" , issue = "138215 " ) ]
53+ #[ stable ( feature = "int_format_into" , since = "CURRENT_RUSTC_VERSION " ) ]
5454pub struct NumBuffer < T : NumBufferTrait > {
5555 // FIXME: Once const generics feature is working, use `T::BUF_SIZE` instead of 40.
5656 pub ( crate ) buf : [ MaybeUninit < u8 > ; 40 ] ,
5757 // FIXME: Remove this field once we can actually use `T`.
5858 phantom : core:: marker:: PhantomData < T > ,
5959}
6060
61- #[ unstable ( feature = "int_format_into" , issue = "138215 " ) ]
61+ #[ stable ( feature = "int_format_into" , since = "CURRENT_RUSTC_VERSION " ) ]
6262impl < T : NumBufferTrait > core:: fmt:: Debug for NumBuffer < T > {
6363 fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
6464 f. debug_struct ( "NumBuffer" ) . finish ( )
6565 }
6666}
6767
68- #[ unstable ( feature = "int_format_into" , issue = "138215 " ) ]
68+ #[ stable ( feature = "int_format_into" , since = "CURRENT_RUSTC_VERSION " ) ]
6969impl < T : NumBufferTrait > NumBuffer < T > {
7070 /// Initializes internal buffer.
71- #[ unstable( feature = "int_format_into" , issue = "138215" ) ]
71+ #[ stable( feature = "int_format_into" , since = "CURRENT_RUSTC_VERSION" ) ]
72+ #[ rustc_const_stable( feature = "int_format_into" , since = "CURRENT_RUSTC_VERSION" ) ]
7273 pub const fn new ( ) -> Self {
7374 // FIXME: Once const generics feature is working, use `T::BUF_SIZE` instead of 40.
7475 NumBuffer { buf : [ MaybeUninit :: < u8 > :: uninit ( ) ; 40 ] , phantom : core:: marker:: PhantomData }
7576 }
7677
77- /// Returns the length of the internal buffer.
78- #[ unstable( feature = "int_format_into" , issue = "138215" ) ]
79- pub const fn capacity ( & self ) -> usize {
78+ pub ( crate ) const fn capacity ( & self ) -> usize {
8079 self . buf . len ( )
8180 }
8281}
0 commit comments