use $( ... )* syntax

This commit is contained in:
AsukaMinato 2023-03-20 16:15:21 +09:00 committed by Peter Ammon
parent 732f7284d4
commit 2e66bb19da

View file

@ -33,37 +33,33 @@ fn to_wstring_impl(mut val: u64, neg: bool) -> WString {
/// Implement to_wstring() for signed types. /// Implement to_wstring() for signed types.
macro_rules! impl_to_wstring_signed { macro_rules! impl_to_wstring_signed {
($t:ty) => { ($($t:ty), *) => {
$(
impl ToWString for $t { impl ToWString for $t {
fn to_wstring(&self) -> WString { fn to_wstring(&self) -> WString {
let val = *self as i64; let val = *self as i64;
to_wstring_impl(val.unsigned_abs(), val < 0) to_wstring_impl(val.unsigned_abs(), val < 0)
} }
} }
)*
}; };
} }
impl_to_wstring_signed!(i8); impl_to_wstring_signed!(i8, i16, i32, i64, isize);
impl_to_wstring_signed!(i16);
impl_to_wstring_signed!(i32);
impl_to_wstring_signed!(i64);
impl_to_wstring_signed!(isize);
/// Implement to_wstring() for unsigned types. /// Implement to_wstring() for unsigned types.
macro_rules! impl_to_wstring_unsigned { macro_rules! impl_to_wstring_unsigned {
($t:ty) => { ($($t:ty), *) => {
$(
impl ToWString for $t { impl ToWString for $t {
fn to_wstring(&self) -> WString { fn to_wstring(&self) -> WString {
to_wstring_impl(*self as u64, false) to_wstring_impl(*self as u64, false)
} }
} }
)*
}; };
} }
impl_to_wstring_unsigned!(u8); impl_to_wstring_unsigned!(u8, u16, u32, u64, usize);
impl_to_wstring_unsigned!(u16);
impl_to_wstring_unsigned!(u32);
impl_to_wstring_unsigned!(u64);
impl_to_wstring_unsigned!(usize);
#[test] #[test]
fn test_to_wstring() { fn test_to_wstring() {