mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 01:17:45 +00:00
use $( ... )* syntax
This commit is contained in:
parent
732f7284d4
commit
2e66bb19da
1 changed files with 8 additions and 12 deletions
|
@ -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() {
|
||||||
|
|
Loading…
Reference in a new issue