Skip to content

Commit 70d6cf0

Browse files
committed
AVRO-3631: Fix clippy and Rat issues
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
1 parent 7c9e938 commit 70d6cf0

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

lang/rust/avro/src/ser.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
//! Logic for serde-compatible serialization.
1919
use crate::{types::Value, Error};
20-
use ref_thread_local::ref_thread_local;
21-
use ref_thread_local::RefThreadLocal;
20+
use ref_thread_local::{ref_thread_local, RefThreadLocal};
2221
use serde::{ser, Serialize};
2322
use std::{collections::HashMap, iter::once};
2423

@@ -1097,19 +1096,19 @@ mod tests {
10971096
),
10981097
(
10991098
"fixed_field".to_owned(),
1100-
Value::Fixed(6, Vec::from(test.fixed_field.clone())),
1099+
Value::Fixed(6, Vec::from(test.fixed_field)),
11011100
),
11021101
(
11031102
"fixed_field2".to_owned(),
1104-
Value::Fixed(2, Vec::from(test.fixed_field2.clone())),
1103+
Value::Fixed(2, Vec::from(test.fixed_field2)),
11051104
),
11061105
(
11071106
"bytes_field".to_owned(),
1108-
Value::Bytes(Vec::from(test.bytes_field.clone())),
1107+
Value::Bytes(Vec::from(test.bytes_field)),
11091108
),
11101109
(
11111110
"bytes_field2".to_owned(),
1112-
Value::Bytes(Vec::from(test.bytes_field2.clone())),
1111+
Value::Bytes(Vec::from(test.bytes_field2)),
11131112
),
11141113
(
11151114
"vec_field".to_owned(),

lang/rust/avro/src/types.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,11 +2399,14 @@ Field with name '"b"' is not a member of the map items"#,
23992399

24002400
#[test]
24012401
fn avro_3631_test_serialize_fixed_fields() {
2402+
use crate::{avro_serialize_bytes, avro_serialize_fixed};
2403+
24022404
#[derive(Debug, Serialize, Deserialize)]
24032405
struct TestStructFixedField<'a> {
2406+
#[serde(serialize_with = "avro_serialize_bytes")]
24042407
bytes_field: &'a [u8],
24052408
vec_field: Vec<u8>,
2406-
#[serde(with = "serde_bytes")]
2409+
#[serde(serialize_with = "avro_serialize_fixed")]
24072410
fixed_field: [u8; 6],
24082411
// #[serde(with = "serde_bytes")]
24092412
// #[serde(with = "serde_bytes")]

lang/rust/avro/tests/ser.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1-
use apache_avro::to_value;
2-
use apache_avro::types::Value;
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
use apache_avro::{to_value, types::Value};
319
use serde::{Deserialize, Serialize};
420

521
#[test]
@@ -25,11 +41,11 @@ fn avro_3631_visibility_of_avro_serialize_bytes_type() {
2541
let expected = Value::Record(vec![
2642
(
2743
"bytes_field".to_owned(),
28-
Value::Bytes(Vec::from(test.bytes_field.clone())),
44+
Value::Bytes(Vec::from(test.bytes_field)),
2945
),
3046
(
3147
"fixed_field".to_owned(),
32-
Value::Fixed(6, Vec::from(test.fixed_field.clone())),
48+
Value::Fixed(6, Vec::from(test.fixed_field)),
3349
),
3450
]);
3551

0 commit comments

Comments
 (0)