diff --git a/logos/src/source.rs b/logos/src/source.rs index 4ca46b00..0f0496ab 100644 --- a/logos/src/source.rs +++ b/logos/src/source.rs @@ -219,20 +219,11 @@ impl<'source> Chunk<'source> for u8 { } } -macro_rules! impl_array { - ($($size:expr),*) => ($( - impl<'source> Chunk<'source> for &'source [u8; $size] { - const SIZE: usize = $size; - - #[inline] - unsafe fn from_ptr(ptr: *const u8) -> Self { - &*(ptr as *const [u8; $size]) - } - } - )*); -} +impl<'source, const N: usize> Chunk<'source> for &'source [u8; N] { + const SIZE: usize = N; -impl_array!( - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32 -); + #[inline] + unsafe fn from_ptr(ptr: *const u8) -> Self { + &*(ptr as *const [u8; N]) + } +}