From e37f8acc6ceddb26992052a069e14571230c44b1 Mon Sep 17 00:00:00 2001 From: zhongzc Date: Thu, 16 Apr 2020 19:22:27 +0800 Subject: [PATCH] clippy Signed-off-by: zhongzc --- .../src/codec/data_type/mod.rs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/components/tidb_query_datatype/src/codec/data_type/mod.rs b/components/tidb_query_datatype/src/codec/data_type/mod.rs index 3e2ac782d9f..944aec63123 100644 --- a/components/tidb_query_datatype/src/codec/data_type/mod.rs +++ b/components/tidb_query_datatype/src/codec/data_type/mod.rs @@ -43,7 +43,7 @@ impl AsMySQLBool for Real { impl AsMySQLBool for Bytes { #[inline] fn as_mysql_bool(&self, context: &mut EvalContext) -> Result { - Ok(!self.is_empty() && ConvertTo::::convert(self, context)? != 0.0) + Ok(!self.is_empty() && ConvertTo::::convert(self, context)? != 0f64) } } @@ -140,7 +140,10 @@ mod tests { (b"0x00", None), (b"11.xx", None), (b"xx.11", None), - (b".0000000000000000000000000000000000000000000000000000001", Some(true)) + ( + b".0000000000000000000000000000000000000000000000000000001", + Some(true), + ), ]; let mut ctx = EvalContext::default(); @@ -164,11 +167,19 @@ mod tests { // test overflow let mut ctx = EvalContext::default(); - let val: Result = f64::INFINITY.to_string().as_bytes().to_vec().as_mysql_bool(&mut ctx); + let val: Result = f64::INFINITY + .to_string() + .as_bytes() + .to_vec() + .as_mysql_bool(&mut ctx); assert!(val.is_err()); let mut ctx = EvalContext::default(); - let val: Result = f64::NEG_INFINITY.to_string().as_bytes().to_vec().as_mysql_bool(&mut ctx); + let val: Result = f64::NEG_INFINITY + .to_string() + .as_bytes() + .to_vec() + .as_mysql_bool(&mut ctx); assert!(val.is_err()); } -} \ No newline at end of file +}