From 260dfafbd90edaa05a77431219d8a623b0667db6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 12 Dec 2021 11:50:52 -0800 Subject: [PATCH] Move buffer type to associated type of IntegerPrivate --- src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5037aa2..9c665cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,8 +104,9 @@ mod private { } } -trait IntegerPrivate { - fn write_to(self, buf: &mut B) -> &str; +trait IntegerPrivate { + type Buffer; + fn write_to(self, buf: &mut Self::Buffer) -> &str; } const DEC_DIGITS_LUT: &[u8] = b"\ @@ -141,7 +142,9 @@ macro_rules! impl_Integer { ($($max_len:expr => $t:ident),* as $conv_fn:ident) => {$( impl_IntegerCommon!($max_len, $t); - impl IntegerPrivate<[MaybeUninit; $max_len]> for $t { + impl IntegerPrivate for $t { + type Buffer = [MaybeUninit; $max_len]; + #[allow(unused_comparisons)] #[inline] fn write_to(self, buf: &mut [MaybeUninit; $max_len]) -> &str { @@ -240,7 +243,9 @@ macro_rules! impl_Integer128 { ($($max_len:expr => $t:ident),*) => {$( impl_IntegerCommon!($max_len, $t); - impl IntegerPrivate<[MaybeUninit; $max_len]> for $t { + impl IntegerPrivate for $t { + type Buffer = [MaybeUninit; $max_len]; + #[allow(unused_comparisons)] #[inline] fn write_to(self, buf: &mut [MaybeUninit; $max_len]) -> &str {