Skip to content

Commit 5f6a2c5

Browse files
cyborg42fede1024
authored andcommitted
Impl ToBytes for [u8; N] with generic const
1 parent e7d863f commit 5f6a2c5

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/message.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -822,24 +822,12 @@ impl ToBytes for () {
822822
}
823823
}
824824

825-
// Implement to_bytes for arrays - https://github.com/rust-lang/rfcs/issues/1038
826-
macro_rules! array_impls {
827-
($($N:expr)+) => {
828-
$(
829-
impl ToBytes for [u8; $N] {
830-
fn to_bytes(&self) -> &[u8] { self }
831-
}
832-
)+
825+
impl<const N: usize> ToBytes for [u8; N] {
826+
fn to_bytes(&self) -> &[u8] {
827+
self
833828
}
834829
}
835830

836-
array_impls! {
837-
0 1 2 3 4 5 6 7 8 9
838-
10 11 12 13 14 15 16 17 18 19
839-
20 21 22 23 24 25 26 27 28 29
840-
30 31 32
841-
}
842-
843831
#[cfg(test)]
844832
mod test {
845833
use super::*;

0 commit comments

Comments
 (0)