From cab559b9d954a02237636f704bfd23909d524732 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Thu, 17 Jul 2025 21:05:13 +0800 Subject: [PATCH] aya-log: Use `None` instead of wildcard in `Format` impls The `Format` implementations for various types were using a wildcard `_` to match the `None` case on `Option`. This is incorrect as it would also match any `Some(...)` variants that were not explicitly handled, leading to unexpected behavior. This commit changes the wildcard `_` to an explicit `None` match to ensure that only the `None` case is handled, making the matching more explicit and correct. Signed-off-by: Xiaobo Liu --- aya-log/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aya-log/src/lib.rs b/aya-log/src/lib.rs index e34c3ba6..a4e76e62 100644 --- a/aya-log/src/lib.rs +++ b/aya-log/src/lib.rs @@ -295,7 +295,7 @@ impl Format for u32 { Some(DisplayHint::Ip) => Ok(Ipv4Formatter::format(*self)), Some(DisplayHint::LowerMac) => Err(()), Some(DisplayHint::UpperMac) => Err(()), - _ => Ok(DefaultFormatter::format(self)), + None => Ok(DefaultFormatter::format(self)), } } } @@ -351,7 +351,7 @@ impl Format for [u8; 6] { Some(DisplayHint::Ip) => Err(()), Some(DisplayHint::LowerMac) => Ok(LowerMacFormatter::format(*self)), Some(DisplayHint::UpperMac) => Ok(UpperMacFormatter::format(*self)), - _ => Err(()), + None => Err(()), } } } @@ -365,7 +365,7 @@ impl Format for [u8; 16] { Some(DisplayHint::Ip) => Ok(Ipv6Formatter::format(*self)), Some(DisplayHint::LowerMac) => Err(()), Some(DisplayHint::UpperMac) => Err(()), - _ => Err(()), + None => Err(()), } } } @@ -379,7 +379,7 @@ impl Format for [u16; 8] { Some(DisplayHint::Ip) => Ok(Ipv6Formatter::format(*self)), Some(DisplayHint::LowerMac) => Err(()), Some(DisplayHint::UpperMac) => Err(()), - _ => Err(()), + None => Err(()), } } } @@ -395,7 +395,7 @@ macro_rules! impl_format { Some(DisplayHint::Ip) => Err(()), Some(DisplayHint::LowerMac) => Err(()), Some(DisplayHint::UpperMac) => Err(()), - _ => Ok(DefaultFormatter::format(self)), + None => Ok(DefaultFormatter::format(self)), } } } @@ -424,7 +424,7 @@ macro_rules! impl_format_float { Some(DisplayHint::Ip) => Err(()), Some(DisplayHint::LowerMac) => Err(()), Some(DisplayHint::UpperMac) => Err(()), - _ => Ok(DefaultFormatter::format(self)), + None => Ok(DefaultFormatter::format(self)), } } }