diff --git a/src/lib.rs b/src/lib.rs index b8344f6..d85cac7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -232,6 +232,18 @@ macro_rules! concat_slices { &ARR }}; + ([char]: $($s:expr),+ $(,)?) => { + $crate::concat_slices!(['\x00'; char]: $($s),+) + }; + + ([f32]: $($s:expr),+ $(,)?) => { + $crate::concat_slices!([0.0; f32]: $($s),+) + }; + + ([f64]: $($s:expr),+ $(,)?) => { + $crate::concat_slices!([0.0; f64]: $($s),+) + }; + ([$T:ty]: $($s:expr),+ $(,)?) => { $crate::concat_slices!([0; $T]: $($s),+) }; diff --git a/tests/smoke.rs b/tests/smoke.rs index 9da896f..fbe589a 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -69,20 +69,26 @@ fn concat_slices_smoke() { const TEST2: &[i32] = concat_slices!([i32]: &[1, 2, 3], TEST1); assert_eq!(TEST2, [1, 2, 3, 1, 2, 3]); - const TEST3: &[f32] = concat_slices!([0.; f32]: &[1.], &[2.], &[3.]); + const TEST3: &[f32] = concat_slices!([f32]: &[1.], &[2.], &[3.]); assert_eq!(TEST3, [1., 2., 3.]); - const TEST4: &[char] = concat_slices!(['\x00'; char]: &['a'], &['b'], &['c']); + const TEST4: &[char] = concat_slices!([char]: &['a'], &['b'], &['c']); assert_eq!(TEST4, ['a', 'b', 'c']); + const TEST5: &[f32] = concat_slices!([1.0; f32]: &[1.], &[2.], &[3.]); + assert_eq!(TEST5, [1., 2., 3.]); + + const TEST6: &[char] = concat_slices!(['0'; char]: &['a'], &['b'], &['c']); + assert_eq!(TEST6, ['a', 'b', 'c']); + #[derive(Debug, Clone, Copy, PartialEq, Eq)] struct I(i32); - const TEST5: &[I] = concat_slices!([I(0); I]: &[I(1), I(2), I(3)]); - assert_eq!(TEST5, [I(1), I(2), I(3)]); + const TEST7: &[I] = concat_slices!([I(0); I]: &[I(1), I(2), I(3)]); + assert_eq!(TEST7, [I(1), I(2), I(3)]); const DEF: I = I(123); - const TEST6: &[I] = concat_slices!([DEF; I]: &[I(1), I(2), I(3)]); - assert_eq!(TEST6, [I(1), I(2), I(3)]); + const TEST8: &[I] = concat_slices!([DEF; I]: &[I(1), I(2), I(3)]); + assert_eq!(TEST8, [I(1), I(2), I(3)]); } #[test]