diff --git a/rust/cubesql/cubesql/Cargo.toml b/rust/cubesql/cubesql/Cargo.toml index dc996a11726c6..e6372fc4731b6 100644 --- a/rust/cubesql/cubesql/Cargo.toml +++ b/rust/cubesql/cubesql/Cargo.toml @@ -90,27 +90,13 @@ harness = false # Feel free to remove any rule from here and fix all warnings with it # Or to write a comment why rule should stay disabled [lints.clippy] -assign_op_pattern = "allow" -bool_assert_comparison = "allow" -bool_comparison = "allow" -borrowed_box = "allow" -cast_abs_to_unsigned = "allow" clone_on_copy = "allow" -cmp_owned = "allow" collapsible_if = "allow" collapsible_match = "allow" collapsible_else_if = "allow" comparison_chain = "allow" derive_ord_xor_partial_ord = "allow" -expect_fun_call = "allow" -explicit_auto_deref = "allow" -extra_unused_lifetimes = "allow" field_reassign_with_default = "allow" -filter_map_bool_then = "allow" -filter_map_identity = "allow" -for_kv_map = "allow" -get_first = "allow" -identity_op = "allow" if_same_then_else = "allow" into_iter_on_ref = "allow" iter_cloned_collect = "allow" @@ -118,12 +104,8 @@ iter_next_slice = "allow" len_without_is_empty = "allow" len_zero = "allow" let_and_return = "allow" -manual_filter = "allow" manual_flatten = "allow" -manual_is_ascii_check = "allow" -manual_map = "allow" manual_range_contains = "allow" -manual_strip = "allow" map_clone = "allow" map_flatten = "allow" map_identity = "allow" @@ -152,11 +134,9 @@ redundant_closure = "allow" redundant_field_names = "allow" redundant_pattern = "allow" redundant_pattern_matching = "allow" -redundant_slicing = "allow" result_large_err = "allow" single_match = "allow" should_implement_trait = "allow" -to_string_in_format_args = "allow" to_string_trait_impl = "allow" too_many_arguments = "allow" type_complexity = "allow" diff --git a/rust/cubesql/cubesql/e2e/tests/postgres.rs b/rust/cubesql/cubesql/e2e/tests/postgres.rs index 87d17d48a6069..472ad783fcf43 100644 --- a/rust/cubesql/cubesql/e2e/tests/postgres.rs +++ b/rust/cubesql/cubesql/e2e/tests/postgres.rs @@ -83,7 +83,7 @@ impl PostgresIntegrationTestSuite { services.wait_processing_loops().await.unwrap(); }); - sleep(Duration::from_millis(1 * 1000)).await; + sleep(Duration::from_secs(1)).await; let client = PostgresIntegrationTestSuite::create_client( format!("host=127.0.0.1 port={} user=test password=test", port) @@ -142,7 +142,7 @@ impl PostgresIntegrationTestSuite { column.type_().oid(), PgType::get_by_tid( PgTypeId::from_oid(column.type_().oid()) - .expect(&format!("Unknown oid {}", column.type_().oid())) + .unwrap_or_else(|| panic!("Unknown oid {}", column.type_().oid())) ) .typname, )); @@ -150,7 +150,7 @@ impl PostgresIntegrationTestSuite { // We dont need data when with_rows = false, but it's useful for testing that data type is correct match PgTypeId::from_oid(column.type_().oid()) - .expect(&format!("Unknown type oid: {}", column.type_().oid())) + .unwrap_or_else(|| panic!("Unknown type oid: {}", column.type_().oid())) { PgTypeId::INT8 => { let value: Option = row.get(idx); @@ -1269,7 +1269,7 @@ impl AsyncTestSuite for PostgresIntegrationTestSuite { |rows| { assert_eq!(rows.len(), 1); - let columns = rows.get(0).unwrap().columns(); + let columns = rows.first().unwrap().columns(); assert_eq!( columns .into_iter() diff --git a/rust/cubesql/cubesql/src/compile/engine/df/scan.rs b/rust/cubesql/cubesql/src/compile/engine/df/scan.rs index 11d7f03695d5f..48b8faabd0512 100644 --- a/rust/cubesql/cubesql/src/compile/engine/df/scan.rs +++ b/rust/cubesql/cubesql/src/compile/engine/df/scan.rs @@ -754,11 +754,7 @@ impl CubeScanOneShotStream { } fn poll_next(&mut self) -> Option> { - if let Some(batch) = self.data.take() { - Some(Ok(batch)) - } else { - None - } + self.data.take().map(Ok) } } diff --git a/rust/cubesql/cubesql/src/compile/engine/udf/common.rs b/rust/cubesql/cubesql/src/compile/engine/udf/common.rs index 494641bbcac35..97a4bd31c4129 100644 --- a/rust/cubesql/cubesql/src/compile/engine/udf/common.rs +++ b/rust/cubesql/cubesql/src/compile/engine/udf/common.rs @@ -1418,7 +1418,7 @@ fn date_addsub_year_month(t: NaiveDateTime, i: i32, is_add: bool) -> Result return Ok(t), @@ -1442,13 +1442,13 @@ fn date_addsub_month_day_nano( let result = if month > 0 && is_add || month < 0 && !is_add { t.checked_add_months(Months::new(month as u32)) } else { - t.checked_sub_months(Months::new(month.abs() as u32)) + t.checked_sub_months(Months::new(month.unsigned_abs())) }; let result = if day > 0 && is_add || day < 0 && !is_add { result.and_then(|t| t.checked_add_days(Days::new(day as u64))) } else { - result.and_then(|t| t.checked_sub_days(Days::new(day.abs() as u64))) + result.and_then(|t| t.checked_sub_days(Days::new(day.unsigned_abs() as u64))) }; let result = result.and_then(|t| { @@ -1472,7 +1472,7 @@ fn date_addsub_day_time( let result = if days > 0 && is_add || days < 0 && !is_add { t.checked_add_days(Days::new(days as u64)) } else { - t.checked_sub_days(Days::new(days.abs() as u64)) + t.checked_sub_days(Days::new(days.unsigned_abs() as u64)) }; let result = result.and_then(|t| { @@ -1501,9 +1501,9 @@ fn last_day_of_month(y: i32, m: u32) -> u32 { return 31; } NaiveDate::from_ymd_opt(y, m + 1, 1) - .expect(&format!("Invalid year month: {}-{}", y, m)) + .unwrap_or_else(|| panic!("Invalid year month: {}-{}", y, m)) .pred_opt() - .expect(&format!("Invalid year month: {}-{}", y, m)) + .unwrap_or_else(|| panic!("Invalid year month: {}-{}", y, m)) .day() } @@ -1564,10 +1564,7 @@ pub fn create_str_to_date_udf() -> ScalarUDF { let res = NaiveDateTime::parse_from_str(timestamp, &format).map_err(|e| { DataFusionError::Execution(format!( - "Error evaluating str_to_date('{}', '{}'): {}", - timestamp, - format, - e.to_string() + "Error evaluating str_to_date('{timestamp}', '{format}'): {e}" )) })?; @@ -1671,7 +1668,7 @@ pub fn create_to_char_udf() -> ScalarUDF { let secs = duration.num_seconds(); let nanosecs = duration.num_nanoseconds().unwrap_or(0) - secs * 1_000_000_000; let timestamp = NaiveDateTime::from_timestamp_opt(secs, nanosecs as u32) - .expect(format!("Invalid secs {} nanosecs {}", secs, nanosecs).as_str()); + .unwrap_or_else(|| panic!("Invalid secs {} nanosecs {}", secs, nanosecs)); // chrono's strftime is missing quarter format, as such a workaround is required let quarter = &format!("{}", timestamp.date().month0() / 3 + 1); @@ -2237,10 +2234,7 @@ pub fn create_pg_get_constraintdef_udf() -> ScalarUDF { let oids_arr = downcast_primitive_arg!(args[0], "oid", OidType); let result = oids_arr .iter() - .map(|oid| match oid { - Some(_oid) => Some("PRIMARY KEY (oid)".to_string()), - _ => None, - }) + .map(|oid| oid.map(|_oid| "PRIMARY KEY (oid)".to_string())) .collect::(); Ok(Arc::new(result)) @@ -3410,7 +3404,7 @@ pub fn create_array_to_string_udf() -> ScalarUDF { let join_str = join_strs.value(i); let strings = downcast_string_arg!(array, "str", i32); let joined_string = - itertools::Itertools::intersperse(strings.iter().filter_map(|s| s), join_str) + itertools::Itertools::intersperse(strings.iter().flatten(), join_str) .collect::(); builder.append_value(joined_string)?; } diff --git a/rust/cubesql/cubesql/src/compile/engine/variable_provider.rs b/rust/cubesql/cubesql/src/compile/engine/variable_provider.rs index 0edb9e147f9f9..d3c68b9989f60 100644 --- a/rust/cubesql/cubesql/src/compile/engine/variable_provider.rs +++ b/rust/cubesql/cubesql/src/compile/engine/variable_provider.rs @@ -25,7 +25,7 @@ impl VariablesProvider { fn get_session_value(&self, identifier: Vec, var_type: VarType) -> Result { let key = if identifier.len() > 1 { - let ignore_first = identifier[0].to_ascii_lowercase() == "@@session".to_owned(); + let ignore_first = identifier[0].to_ascii_lowercase() == "@@session"; if ignore_first { identifier[1..].concat() } else { @@ -48,7 +48,7 @@ impl VariablesProvider { fn get_global_value(&self, identifier: Vec) -> Result { let key = if identifier.len() > 1 { - let ignore_first = identifier[0].to_ascii_lowercase() == "@@global".to_owned(); + let ignore_first = identifier[0].to_ascii_lowercase() == "@@global"; if ignore_first { identifier[1..].concat() @@ -85,9 +85,7 @@ impl VarProvider for VariablesProvider { match (&first_word_vec[0], &first_word_vec[1]) { ('@', '@') => { - if identifier.len() > 1 - && identifier[0].to_ascii_lowercase() == "@@session".to_owned() - { + if identifier.len() > 1 && identifier[0].to_ascii_lowercase() == "@@session" { return self.get_session_value(identifier, VarType::System); } diff --git a/rust/cubesql/cubesql/src/compile/parser.rs b/rust/cubesql/cubesql/src/compile/parser.rs index 95bd7e6175cc3..9ea3f3f73746b 100644 --- a/rust/cubesql/cubesql/src/compile/parser.rs +++ b/rust/cubesql/cubesql/src/compile/parser.rs @@ -23,8 +23,8 @@ impl Dialect for MySqlDialectWithBackTicks { // See https://dev.mysql.com/doc/refman/8.0/en/identifiers.html. // We don't yet support identifiers beginning with numbers, as that // makes it hard to distinguish numeric literals. - ('a'..='z').contains(&ch) - || ('A'..='Z').contains(&ch) + ch.is_ascii_lowercase() + || ch.is_ascii_uppercase() || ch == '_' || ch == '$' || ch == '@' @@ -32,7 +32,7 @@ impl Dialect for MySqlDialectWithBackTicks { } fn is_identifier_part(&self, ch: char) -> bool { - self.is_identifier_start(ch) || ('0'..='9').contains(&ch) + self.is_identifier_start(ch) || ch.is_ascii_digit() } } @@ -293,11 +293,9 @@ mod tests { ); match result { Ok(_) => panic!("This test should throw an error"), - Err(err) => assert_eq!( - true, - err.to_string() - .contains("Invalid query, no statements was specified") - ), + Err(err) => assert!(err + .to_string() + .contains("Invalid query, no statements was specified")), } } @@ -310,11 +308,9 @@ mod tests { ); match result { Ok(_) => panic!("This test should throw an error"), - Err(err) => assert_eq!( - true, - err.to_string() - .contains("Multiple statements was specified in one query") - ), + Err(err) => assert!(err + .to_string() + .contains("Multiple statements was specified in one query")), } } @@ -349,11 +345,9 @@ mod tests { ); match result { Ok(_) => panic!("This test should throw an error"), - Err(err) => assert_eq!( - true, - err.to_string() - .contains("Invalid query, no statements was specified") - ), + Err(err) => assert!(err + .to_string() + .contains("Invalid query, no statements was specified")), } } @@ -366,11 +360,9 @@ mod tests { ); match result { Ok(_) => panic!("This test should throw an error"), - Err(err) => assert_eq!( - true, - err.to_string() - .contains("Multiple statements was specified in one query") - ), + Err(err) => assert!(err + .to_string() + .contains("Multiple statements was specified in one query")), } } diff --git a/rust/cubesql/cubesql/src/compile/rewrite/analysis.rs b/rust/cubesql/cubesql/src/compile/rewrite/analysis.rs index a5df8018f19e4..ff911a59518a7 100644 --- a/rust/cubesql/cubesql/src/compile/rewrite/analysis.rs +++ b/rust/cubesql/cubesql/src/compile/rewrite/analysis.rs @@ -551,7 +551,7 @@ impl LogicalPlanAnalysis { .unwrap(); let expr = original_expr(params[2])?; map.push(( - Some(format!("{}.{}", cube, field_name.to_string())), + Some(format!("{cube}.{field_name}")), Member::VirtualField { name: field_name.to_string(), cube: cube.to_string(), diff --git a/rust/cubesql/cubesql/src/compile/rewrite/rewriter.rs b/rust/cubesql/cubesql/src/compile/rewrite/rewriter.rs index 02f299617be70..87dc2f2768dff 100644 --- a/rust/cubesql/cubesql/src/compile/rewrite/rewriter.rs +++ b/rust/cubesql/cubesql/src/compile/rewrite/rewriter.rs @@ -558,10 +558,12 @@ impl egg::RewriteScheduler for Increme if iteration != self.current_iter { self.current_iter = iteration; self.current_eclasses.clear(); - self.current_eclasses - .extend(egraph.classes().filter_map(|class| { - (class.data.iteration_timestamp >= iteration).then(|| class.id) - })); + self.current_eclasses.extend( + egraph + .classes() + .filter(|class| (class.data.iteration_timestamp >= iteration)) + .map(|class| class.id), + ); }; assert_eq!(iteration, self.current_iter); rewrite.searcher.search_eclasses_with_limit( diff --git a/rust/cubesql/cubesql/src/compile/rewrite/rules/filters.rs b/rust/cubesql/cubesql/src/compile/rewrite/rules/filters.rs index 0246487be65ed..1a70f8e871a0c 100644 --- a/rust/cubesql/cubesql/src/compile/rewrite/rules/filters.rs +++ b/rust/cubesql/cubesql/src/compile/rewrite/rules/filters.rs @@ -2780,12 +2780,13 @@ impl FilterRules { value.to_string() } } else if op == "endsWith" || op == "notEndsWith" { - if value.starts_with("%") { - let without_wildcard = value[1..].to_string(); + if let Some(without_wildcard) = + value.strip_prefix("%") + { if without_wildcard.contains("%") { continue; } - without_wildcard + without_wildcard.to_string() } else { value.to_string() } diff --git a/rust/cubesql/cubesql/src/compile/router.rs b/rust/cubesql/cubesql/src/compile/router.rs index 6d5bf3a8f1f77..b4d933a1fc1de 100644 --- a/rust/cubesql/cubesql/src/compile/router.rs +++ b/rust/cubesql/cubesql/src/compile/router.rs @@ -168,8 +168,7 @@ impl QueryRouter { DatabaseProtocol::PostgreSQL, ) if object_type == &ast::ObjectType::Table => self.drop_table_to_plan(names).await, _ => Err(CompilationError::unsupported(format!( - "Unsupported query type: {}", - stmt.to_string() + "Unsupported query type: {stmt}" ))), }; @@ -348,7 +347,7 @@ impl QueryRouter { } DatabaseProtocol::MySQL => { for key_value in key_values.iter() { - if key_value.key.value.to_lowercase() == "autocommit".to_string() { + if key_value.key.value.to_lowercase() == "autocommit" { flags |= StatusFlags::AUTOCOMMIT; break; @@ -513,7 +512,7 @@ impl QueryRouter { async fn select_into_to_plan( &self, into: &ast::SelectInto, - query: &Box, + query: &ast::Query, qtrace: &mut Option, span_id: Option>, ) -> Result { @@ -531,7 +530,7 @@ impl QueryRouter { "query is unexpectedly not SELECT".to_string(), )); } - let new_stmt = ast::Statement::Query(new_query); + let new_stmt = ast::Statement::Query(Box::new(new_query)); self.create_table_to_plan(&into.name, &new_stmt, qtrace, span_id) .await } diff --git a/rust/cubesql/cubesql/src/sql/postgres/extended.rs b/rust/cubesql/cubesql/src/sql/postgres/extended.rs index 13d31e1084881..fc57a7efdf5be 100644 --- a/rust/cubesql/cubesql/src/sql/postgres/extended.rs +++ b/rust/cubesql/cubesql/src/sql/postgres/extended.rs @@ -401,7 +401,7 @@ impl Portal { batch } else { - *left = *left - batch.num_rows(); + *left -= batch.num_rows(); batch } }; diff --git a/rust/cubesql/cubesql/src/sql/postgres/shim.rs b/rust/cubesql/cubesql/src/sql/postgres/shim.rs index 357fca54ca62e..5e99376d308ad 100644 --- a/rust/cubesql/cubesql/src/sql/postgres/shim.rs +++ b/rust/cubesql/cubesql/src/sql/postgres/shim.rs @@ -311,7 +311,7 @@ impl AsyncPostgresShim { fn is_semifast_shutdownable(&self) -> bool { return self.cursors.is_empty() && self.portals.is_empty() - && Self::session_state_is_semifast_shutdownable(&*self.session.state); + && Self::session_state_is_semifast_shutdownable(&self.session.state); } fn admin_shutdown_error() -> ConnectionError { @@ -1336,7 +1336,7 @@ impl AsyncPostgresShim { .await?; } Statement::Rollback { .. } => { - if self.end_transaction()? == false { + if !self.end_transaction()? { // PostgreSQL returns command completion anyway self.write(protocol::NoticeResponse::warning( ErrorCode::NoActiveSqlTransaction, @@ -1355,7 +1355,7 @@ impl AsyncPostgresShim { .await?; } Statement::Commit { .. } => { - if self.end_transaction()? == false { + if !self.end_transaction()? { // PostgreSQL returns command completion anyway self.write(protocol::NoticeResponse::warning( ErrorCode::NoActiveSqlTransaction, @@ -1645,17 +1645,10 @@ impl AsyncPostgresShim { Statement::Close { cursor } => { let plan = match cursor { CloseCursor::All => { - let mut portals_to_remove = Vec::new(); - - for (key, _) in &self.cursors { - portals_to_remove.push(key.clone()); - } - - self.cursors = HashMap::new(); - - for key in portals_to_remove { - self.portals.remove(&key); + for key in self.cursors.keys() { + self.portals.remove(key); } + self.cursors.clear(); Ok(QueryPlan::MetaOk( StatusFlags::empty(), diff --git a/rust/cubesql/cubesql/src/sql/postgres/writer.rs b/rust/cubesql/cubesql/src/sql/postgres/writer.rs index c90687bdebbad..5007f4a1bf669 100644 --- a/rust/cubesql/cubesql/src/sql/postgres/writer.rs +++ b/rust/cubesql/cubesql/src/sql/postgres/writer.rs @@ -310,7 +310,7 @@ impl BatchWriter { } } -impl<'a> Serialize for BatchWriter { +impl Serialize for BatchWriter { const CODE: u8 = b'D'; fn serialize(&self) -> Option> { @@ -337,7 +337,7 @@ mod tests { let mut buf = BytesMut::new(); value.to_text(&mut buf).unwrap(); - assert_eq!(&buf.as_ref()[..], expected); + assert_eq!(buf.as_ref(), expected); } #[test] @@ -364,7 +364,7 @@ mod tests { let mut buf = BytesMut::new(); value.to_binary(&mut buf).unwrap(); - assert_eq!(&buf.as_ref()[..], expected); + assert_eq!(buf.as_ref(), expected); } #[test] diff --git a/rust/cubesql/cubesql/src/sql/statement.rs b/rust/cubesql/cubesql/src/sql/statement.rs index 74ac31e4b16f2..9814a80fe6235 100644 --- a/rust/cubesql/cubesql/src/sql/statement.rs +++ b/rust/cubesql/cubesql/src/sql/statement.rs @@ -480,9 +480,7 @@ trait Visitor<'ast, E: Error> { ConnectionError::from(ErrorResponse::error( ErrorCode::SyntaxError, format!( - "Unable to extract position for placeholder, actual: {}, err: {}", - name, - err.to_string() + "Unable to extract position for placeholder, actual: {name}, err: {err}" ), )) })?; diff --git a/rust/cubesql/pg-srv/Cargo.toml b/rust/cubesql/pg-srv/Cargo.toml index fa226a0c60c93..816d7612af15c 100644 --- a/rust/cubesql/pg-srv/Cargo.toml +++ b/rust/cubesql/pg-srv/Cargo.toml @@ -33,7 +33,3 @@ hex = "0.4.3" [lints.clippy] len_without_is_empty = "allow" new_without_default = "allow" -redundant_slicing = "allow" -single_char_add_str = "allow" -single_match = "allow" -to_string_trait_impl = "allow" diff --git a/rust/cubesql/pg-srv/src/buffer.rs b/rust/cubesql/pg-srv/src/buffer.rs index f4c574030cdba..4e6d7711a498b 100644 --- a/rust/cubesql/pg-srv/src/buffer.rs +++ b/rust/cubesql/pg-srv/src/buffer.rs @@ -173,17 +173,14 @@ pub async fn write_direct( message: Message, ) -> Result<(), ProtocolError> { let mut bytes_mut = BytesMut::new(); - match message.serialize() { - Some(buffer) => { - // TODO: Yet another memory copy. - bytes_mut.extend_from_slice(&buffer); - *partial_write = bytes_mut; - writer.write_all_buf(partial_write).await?; - *partial_write = BytesMut::new(); - writer.flush().await?; - } - _ => {} - }; + if let Some(buffer) = message.serialize() { + // TODO: Yet another memory copy. + bytes_mut.extend_from_slice(&buffer); + *partial_write = bytes_mut; + writer.write_all_buf(partial_write).await?; + *partial_write = BytesMut::new(); + writer.flush().await?; + } Ok(()) } @@ -196,19 +193,16 @@ fn message_serialize( packet_buffer.put_u8(message.code()); } - match message.serialize() { - Some(buffer) => { - let size = u32::try_from(buffer.len() + 4).map_err(|_| { - ErrorResponse::error( - ErrorCode::InternalError, - "Unable to convert buffer length to a suitable memory size".to_string(), - ) - })?; - packet_buffer.extend_from_slice(&size.to_be_bytes()); - packet_buffer.extend_from_slice(&buffer); - } - _ => (), - }; + if let Some(buffer) = message.serialize() { + let size = u32::try_from(buffer.len() + 4).map_err(|_| { + ErrorResponse::error( + ErrorCode::InternalError, + "Unable to convert buffer length to a suitable memory size".to_string(), + ) + })?; + packet_buffer.extend_from_slice(&size.to_be_bytes()); + packet_buffer.extend_from_slice(&buffer); + } Ok(()) } diff --git a/rust/cubesql/pg-srv/src/encoding.rs b/rust/cubesql/pg-srv/src/encoding.rs index 1c64d4286037e..34dd67f3350ac 100644 --- a/rust/cubesql/pg-srv/src/encoding.rs +++ b/rust/cubesql/pg-srv/src/encoding.rs @@ -4,7 +4,10 @@ use crate::{protocol::Format, ProtocolError}; use bytes::{BufMut, BytesMut}; #[cfg(feature = "with-chrono")] use chrono::{NaiveDate, NaiveDateTime}; -use std::io::{Error, ErrorKind}; +use std::{ + fmt::{Display, Formatter}, + io::{Error, ErrorKind}, +}; /// This trait explains how to encode values to the protocol format pub trait ToProtocolValue: std::fmt::Debug { @@ -210,7 +213,7 @@ impl IntervalValue { if self.hours != 0 || self.mins != 0 || self.secs != 0 || self.usecs != 0 { if self.hours < 0 || self.mins < 0 || self.secs < 0 || self.usecs < 0 { - res.push_str("-") + res.push('-') }; res.push_str(&format!( @@ -256,10 +259,11 @@ impl IntervalValue { } } -impl ToString for IntervalValue { - // https://github.com/postgres/postgres/blob/REL_14_4/src/interfaces/ecpg/pgtypeslib/interval.c#L763 - fn to_string(&self) -> String { - self.as_postgresql_str() +impl Display for IntervalValue { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + // TODO lift formatter higher, to as_postgresql_str + // https://github.com/postgres/postgres/blob/REL_14_4/src/interfaces/ecpg/pgtypeslib/interval.c#L763 + f.write_str(&self.as_postgresql_str()) } } @@ -294,7 +298,7 @@ mod tests { let mut buf = BytesMut::new(); value.to_text(&mut buf).unwrap(); - assert_eq!(&buf.as_ref()[..], expected); + assert_eq!(buf.as_ref(), expected); } #[test] @@ -310,7 +314,7 @@ mod tests { let mut buf = BytesMut::new(); value.to_binary(&mut buf).unwrap(); - assert_eq!(&buf.as_ref()[..], expected); + assert_eq!(buf.as_ref(), expected); } #[test]