Skip to content

Commit 0d98c12

Browse files
Rollup merge of rust-lang#156098 - joshtriplett:num-buffer-debug, r=GuillaumeGomez
Hand-implement `impl Debug for NumBuffer` to avoid constraining `T` or printing MaybeUninit The derived implementation requires `T: Debug`, and doesn't need to.
2 parents 081e7c4 + df8a13e commit 0d98c12

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

library/core/src/fmt/num_buffer.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,20 @@ impl_NumBufferTrait! {
3535
/// A buffer wrapper of which the internal size is based on the maximum
3636
/// number of digits the associated integer can have.
3737
#[unstable(feature = "int_format_into", issue = "138215")]
38-
#[derive(Debug)]
3938
pub struct NumBuffer<T: NumBufferTrait> {
4039
// FIXME: Once const generics feature is working, use `T::BUF_SIZE` instead of 40.
4140
pub(crate) buf: [MaybeUninit<u8>; 40],
4241
// FIXME: Remove this field once we can actually use `T`.
4342
phantom: core::marker::PhantomData<T>,
4443
}
4544

45+
#[unstable(feature = "int_format_into", issue = "138215")]
46+
impl<T: NumBufferTrait> core::fmt::Debug for NumBuffer<T> {
47+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
48+
f.debug_struct("NumBuffer").finish()
49+
}
50+
}
51+
4652
#[unstable(feature = "int_format_into", issue = "138215")]
4753
impl<T: NumBufferTrait> NumBuffer<T> {
4854
/// Initializes internal buffer.

0 commit comments

Comments
 (0)