From 2c691a4b012ccc1c43d27528598c5f6eded8b11d Mon Sep 17 00:00:00 2001 From: Prabakaran Chinnasamy Date: Tue, 24 Mar 2026 17:56:26 +0530 Subject: [PATCH] datatype: Remove implementation of write_i128 and write_u128 Removed implementation of write_i128 and write_u128 since C++ logging backend does not support 128-bit datatype. --- examples/log_custom/src/logger.rs | 8 ------- src/log/score_log_fmt/fmt.rs | 24 ++----------------- src/log/score_log_fmt/fmt_impl.rs | 12 ---------- src/log/score_log_fmt/test_utils.rs | 8 ------- .../score_log_fmt_macro/tests/utils/mod.rs | 8 ------- src/log/stdout_logger/lib.rs | 8 ------- 6 files changed, 2 insertions(+), 66 deletions(-) diff --git a/examples/log_custom/src/logger.rs b/examples/log_custom/src/logger.rs index 0d2accd3..57ad0dee 100644 --- a/examples/log_custom/src/logger.rs +++ b/examples/log_custom/src/logger.rs @@ -58,10 +58,6 @@ impl ScoreWrite for StringWriter { write!(self.buffer, "{}", v).map_err(|_| Error) } - fn write_i128(&mut self, v: &i128, _spec: &FormatSpec) -> FmtResult { - write!(self.buffer, "{}", v).map_err(|_| Error) - } - fn write_u8(&mut self, v: &u8, _spec: &FormatSpec) -> FmtResult { write!(self.buffer, "{}", v).map_err(|_| Error) } @@ -78,10 +74,6 @@ impl ScoreWrite for StringWriter { write!(self.buffer, "{}", v).map_err(|_| Error) } - fn write_u128(&mut self, v: &u128, _spec: &FormatSpec) -> FmtResult { - write!(self.buffer, "{}", v).map_err(|_| Error) - } - fn write_str(&mut self, v: &str, _spec: &FormatSpec) -> FmtResult { write!(self.buffer, "{}", v).map_err(|_| Error) } diff --git a/src/log/score_log_fmt/fmt.rs b/src/log/score_log_fmt/fmt.rs index 46741968..05ac5aa4 100644 --- a/src/log/score_log_fmt/fmt.rs +++ b/src/log/score_log_fmt/fmt.rs @@ -48,8 +48,6 @@ pub trait ScoreWrite { fn write_i32(&mut self, v: &i32, spec: &FormatSpec) -> Result; /// Write a `i64` into this writer. fn write_i64(&mut self, v: &i64, spec: &FormatSpec) -> Result; - /// Write a `i128` into this writer. - fn write_i128(&mut self, v: &i128, spec: &FormatSpec) -> Result; /// Write a `u8` into this writer. fn write_u8(&mut self, v: &u8, spec: &FormatSpec) -> Result; /// Write a `u16` into this writer. @@ -58,8 +56,6 @@ pub trait ScoreWrite { fn write_u32(&mut self, v: &u32, spec: &FormatSpec) -> Result; /// Write a `u64` into this writer. fn write_u64(&mut self, v: &u64, spec: &FormatSpec) -> Result; - /// Write a `u128` into this writer. - fn write_u128(&mut self, v: &u128, spec: &FormatSpec) -> Result; /// Write a `&str` into this writer. fn write_str(&mut self, v: &str, spec: &FormatSpec) -> Result; } @@ -158,18 +154,10 @@ mod tests { Fragment::Placeholder(Placeholder::new(&-1234i16, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&-123456i32, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&-1200000000000000000i64, FormatSpec::new())), - Fragment::Placeholder(Placeholder::new( - &-128000000000000000000000000000000000000i128, - FormatSpec::new(), - )), Fragment::Placeholder(Placeholder::new(&123u8, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&1234u16, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&123456u32, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&1200000000000000000u64, FormatSpec::new())), - Fragment::Placeholder(Placeholder::new( - &128000000000000000000000000000000000000u128, - FormatSpec::new(), - )), Fragment::Literal("_string"), ]; let args = Arguments(&fragments); @@ -177,7 +165,7 @@ mod tests { let result = ScoreDebug::fmt(&args, &mut w, &FormatSpec::new()); assert!(result == Ok(())); assert!( - w.get() == "test_true123.4432.2-100-1234-123456-1200000000000000000-12800000000000000000000000000000000000012312341234561200000000000000000128000000000000000000000000000000000000_string" + w.get() == "test_true123.4432.2-100-1234-123456-120000000000000000012312341234561200000000000000000_string" ) } @@ -207,24 +195,16 @@ mod tests { Fragment::Placeholder(Placeholder::new(&-1234i16, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&-123456i32, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&-1200000000000000000i64, FormatSpec::new())), - Fragment::Placeholder(Placeholder::new( - &-128000000000000000000000000000000000000i128, - FormatSpec::new(), - )), Fragment::Placeholder(Placeholder::new(&123u8, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&1234u16, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&123456u32, FormatSpec::new())), Fragment::Placeholder(Placeholder::new(&1200000000000000000u64, FormatSpec::new())), - Fragment::Placeholder(Placeholder::new( - &128000000000000000000000000000000000000u128, - FormatSpec::new(), - )), Fragment::Placeholder(Placeholder::new(&"test", FormatSpec::new())), ]; let args = Arguments(&fragments); assert!(write(&mut w, args) == Ok(())); - let exp_pattern = "true123.4432.2-100-1234-123456-1200000000000000000-12800000000000000000000000000000000000012312341234561200000000000000000128000000000000000000000000000000000000test"; + let exp_pattern = "true123.4432.2-100-1234-123456-120000000000000000012312341234561200000000000000000test"; assert_eq!(w.get(), exp_pattern); } diff --git a/src/log/score_log_fmt/fmt_impl.rs b/src/log/score_log_fmt/fmt_impl.rs index 8ebd5aa4..d3b83179 100644 --- a/src/log/score_log_fmt/fmt_impl.rs +++ b/src/log/score_log_fmt/fmt_impl.rs @@ -35,12 +35,10 @@ impl_debug_for_t!(i8, write_i8); impl_debug_for_t!(i16, write_i16); impl_debug_for_t!(i32, write_i32); impl_debug_for_t!(i64, write_i64); -impl_debug_for_t!(i128, write_i128); impl_debug_for_t!(u8, write_u8); impl_debug_for_t!(u16, write_u16); impl_debug_for_t!(u32, write_u32); impl_debug_for_t!(u64, write_u64); -impl_debug_for_t!(u128, write_u128); impl ScoreDebug for () { fn fmt(&self, f: Writer, spec: &FormatSpec) -> Result { @@ -281,11 +279,6 @@ mod tests { common_test_debug(-1200000000000000000i64); } - #[test] - fn test_i128_debug() { - common_test_debug(-128000000000000000000000000000000000000i128); - } - #[test] fn test_u8_debug() { common_test_debug(123u8); @@ -306,11 +299,6 @@ mod tests { common_test_debug(1200000000000000000u64); } - #[test] - fn test_u128_debug() { - common_test_debug(128000000000000000000000000000000000000u128); - } - #[test] fn test_unit_debug() { common_test_debug(()); diff --git a/src/log/score_log_fmt/test_utils.rs b/src/log/score_log_fmt/test_utils.rs index 0420998b..efd6adef 100644 --- a/src/log/score_log_fmt/test_utils.rs +++ b/src/log/score_log_fmt/test_utils.rs @@ -65,10 +65,6 @@ impl ScoreWrite for StringWriter { Ok(write!(self.buf, "{}", v)?) } - fn write_i128(&mut self, v: &i128, _spec: &FormatSpec) -> Result { - Ok(write!(self.buf, "{}", v)?) - } - fn write_u8(&mut self, v: &u8, _spec: &FormatSpec) -> Result { Ok(write!(self.buf, "{}", v)?) } @@ -85,10 +81,6 @@ impl ScoreWrite for StringWriter { Ok(write!(self.buf, "{}", v)?) } - fn write_u128(&mut self, v: &u128, _spec: &FormatSpec) -> Result { - Ok(write!(self.buf, "{}", v)?) - } - fn write_str(&mut self, v: &str, _spec: &FormatSpec) -> Result { Ok(write!(self.buf, "{}", v)?) } diff --git a/src/log/score_log_fmt_macro/tests/utils/mod.rs b/src/log/score_log_fmt_macro/tests/utils/mod.rs index cbf22518..e042aa77 100644 --- a/src/log/score_log_fmt_macro/tests/utils/mod.rs +++ b/src/log/score_log_fmt_macro/tests/utils/mod.rs @@ -59,10 +59,6 @@ impl ScoreWrite for StringWriter { write!(self.buf, "{}", v).map_err(|_| Error) } - fn write_i128(&mut self, v: &i128, _spec: &FormatSpec) -> Result { - write!(self.buf, "{}", v).map_err(|_| Error) - } - fn write_u8(&mut self, v: &u8, _spec: &FormatSpec) -> Result { write!(self.buf, "{}", v).map_err(|_| Error) } @@ -79,10 +75,6 @@ impl ScoreWrite for StringWriter { write!(self.buf, "{}", v).map_err(|_| Error) } - fn write_u128(&mut self, v: &u128, _spec: &FormatSpec) -> Result { - write!(self.buf, "{}", v).map_err(|_| Error) - } - fn write_str(&mut self, v: &str, _spec: &FormatSpec) -> Result { write!(self.buf, "{}", v).map_err(|_| Error) } diff --git a/src/log/stdout_logger/lib.rs b/src/log/stdout_logger/lib.rs index 05d7ef26..174a90f0 100644 --- a/src/log/stdout_logger/lib.rs +++ b/src/log/stdout_logger/lib.rs @@ -141,10 +141,6 @@ impl ScoreWrite for FixedBufWriter { write!(self.buf, "{}", v).map_err(|_| Error) } - fn write_i128(&mut self, v: &i128, _spec: &FormatSpec) -> Result { - write!(self.buf, "{}", v).map_err(|_| Error) - } - fn write_u8(&mut self, v: &u8, _spec: &FormatSpec) -> Result { write!(self.buf, "{}", v).map_err(|_| Error) } @@ -161,10 +157,6 @@ impl ScoreWrite for FixedBufWriter { write!(self.buf, "{}", v).map_err(|_| Error) } - fn write_u128(&mut self, v: &u128, _spec: &FormatSpec) -> Result { - write!(self.buf, "{}", v).map_err(|_| Error) - } - fn write_str(&mut self, v: &str, _spec: &FormatSpec) -> Result { write!(self.buf, "{}", v).map_err(|_| Error) }