This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new 79e503357 AVRO-3766: [Rust] Fix the formatting
79e503357 is described below
commit 79e5033578bb8a5c36d48b502c35ba4edd9826e8
Author: Martin Tzvetanov Grigorov <[email protected]>
AuthorDate: Wed May 31 18:35:18 2023 +0300
AVRO-3766: [Rust] Fix the formatting
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
---
lang/rust/avro/src/codec.rs | 12 +--
lang/rust/avro/src/decimal.rs | 2 +-
lang/rust/avro/src/decode.rs | 11 +--
lang/rust/avro/src/reader.rs | 7 +-
lang/rust/avro/src/schema.rs | 144 ++++++++++++-----------------
lang/rust/avro/src/schema_compatibility.rs | 2 +-
lang/rust/avro/src/ser.rs | 2 +-
lang/rust/avro/src/types.rs | 82 +++++++---------
lang/rust/avro/src/util.rs | 2 +-
lang/rust/avro/tests/io.rs | 5 +-
lang/rust/avro/tests/schema.rs | 15 +--
lang/rust/avro/tests/shared.rs | 2 +-
lang/rust/avro_test_helper/src/lib.rs | 2 +-
13 files changed, 115 insertions(+), 173 deletions(-)
diff --git a/lang/rust/avro/src/codec.rs b/lang/rust/avro/src/codec.rs
index c34da0bfc..4e3634697 100644
--- a/lang/rust/avro/src/codec.rs
+++ b/lang/rust/avro/src/codec.rs
@@ -185,8 +185,8 @@ impl Codec {
#[cfg(test)]
mod tests {
use super::*;
- use pretty_assertions::{assert_eq, assert_ne};
use apache_avro_test_helper::TestResult;
+ use pretty_assertions::{assert_eq, assert_ne};
const INPUT: &[u8] =
b"theanswertolifetheuniverseandeverythingis42theanswertolifetheuniverseandeverythingis4theanswertolifetheuniverseandeverythingis2";
@@ -202,31 +202,31 @@ mod tests {
}
#[test]
- fn deflate_compress_and_decompress()-> TestResult {
+ fn deflate_compress_and_decompress() -> TestResult {
compress_and_decompress(Codec::Deflate)
}
#[cfg(feature = "snappy")]
#[test]
- fn snappy_compress_and_decompress()-> TestResult {
+ fn snappy_compress_and_decompress() -> TestResult {
compress_and_decompress(Codec::Snappy)
}
#[cfg(feature = "zstandard")]
#[test]
- fn zstd_compress_and_decompress()-> TestResult {
+ fn zstd_compress_and_decompress() -> TestResult {
compress_and_decompress(Codec::Zstandard)
}
#[cfg(feature = "bzip")]
#[test]
- fn bzip_compress_and_decompress()-> TestResult {
+ fn bzip_compress_and_decompress() -> TestResult {
compress_and_decompress(Codec::Bzip2)
}
#[cfg(feature = "xz")]
#[test]
- fn xz_compress_and_decompress()-> TestResult {
+ fn xz_compress_and_decompress() -> TestResult {
compress_and_decompress(Codec::Xz)
}
diff --git a/lang/rust/avro/src/decimal.rs b/lang/rust/avro/src/decimal.rs
index 4373205df..fb3964373 100644
--- a/lang/rust/avro/src/decimal.rs
+++ b/lang/rust/avro/src/decimal.rs
@@ -102,9 +102,9 @@ impl<T: AsRef<[u8]>> From<T> for Decimal {
#[cfg(test)]
mod tests {
use super::*;
+ use apache_avro_test_helper::TestResult;
use pretty_assertions::assert_eq;
use std::convert::TryFrom;
- use apache_avro_test_helper::TestResult;
#[test]
fn test_decimal_from_bytes_from_ref_decimal() -> TestResult {
diff --git a/lang/rust/avro/src/decode.rs b/lang/rust/avro/src/decode.rs
index 39efefced..debb38076 100644
--- a/lang/rust/avro/src/decode.rs
+++ b/lang/rust/avro/src/decode.rs
@@ -303,9 +303,9 @@ mod tests {
},
Decimal,
};
+ use apache_avro_test_helper::TestResult;
use pretty_assertions::assert_eq;
use std::collections::HashMap;
- use apache_avro_test_helper::TestResult;
#[test]
fn test_decode_array_without_size() -> TestResult {
@@ -431,8 +431,7 @@ mod tests {
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![("z".into(), Value::Int(6))]);
@@ -498,8 +497,7 @@ mod tests {
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![("z".into(), Value::Int(6))]);
@@ -549,8 +547,7 @@ mod tests {
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![("z".into(), Value::Int(6))]);
diff --git a/lang/rust/avro/src/reader.rs b/lang/rust/avro/src/reader.rs
index f83c30f3f..ae0b32de9 100644
--- a/lang/rust/avro/src/reader.rs
+++ b/lang/rust/avro/src/reader.rs
@@ -529,10 +529,10 @@ pub fn read_marker(bytes: &[u8]) -> [u8; 16] {
mod tests {
use super::*;
use crate::{encode::encode, from_value, types::Record, Reader};
+ use apache_avro_test_helper::TestResult;
use pretty_assertions::assert_eq;
use serde::Deserialize;
use std::io::Cursor;
- use apache_avro_test_helper::TestResult;
const SCHEMA: &str = r#"
{
@@ -579,10 +579,7 @@ mod tests {
record.put("b", "foo");
let expected = record.into();
- assert_eq!(
- from_avro_datum(&schema, &mut encoded, None)?,
- expected
- );
+ assert_eq!(from_avro_datum(&schema, &mut encoded, None)?, expected);
Ok(())
}
diff --git a/lang/rust/avro/src/schema.rs b/lang/rust/avro/src/schema.rs
index 907a06222..e0ddd1f0e 100644
--- a/lang/rust/avro/src/schema.rs
+++ b/lang/rust/avro/src/schema.rs
@@ -2071,9 +2071,9 @@ pub mod derive {
#[cfg(test)]
mod tests {
use super::*;
+ use apache_avro_test_helper::TestResult;
use pretty_assertions::assert_eq;
use serde_json::json;
- use apache_avro_test_helper::TestResult;
#[test]
fn test_invalid_schema() {
@@ -2156,18 +2156,15 @@ mod tests {
doc: None,
default: None,
aliases: None,
- schema: Schema::Union(
- UnionSchema::new(vec![
- Schema::Null,
- Schema::Ref {
- name: Name {
- name: "LongList".to_owned(),
- namespace: None,
- },
+ schema: Schema::Union(UnionSchema::new(vec![
+ Schema::Null,
+ Schema::Ref {
+ name: Name {
+ name: "LongList".to_owned(),
+ namespace: None,
},
- ])
- ?,
- ),
+ },
+ ])?),
order: RecordFieldOrder::Ascending,
position: 1,
custom_attributes: Default::default(),
@@ -2235,17 +2232,14 @@ mod tests {
doc: None,
default: None,
aliases: None,
- schema: Schema::Union(
- UnionSchema::new(vec![
- Schema::Ref {
- name: Name::new("A")?,
- },
- Schema::Ref {
- name: Name::new("B")?,
- },
- ])
- ?,
- ),
+ schema: Schema::Union(UnionSchema::new(vec![
+ Schema::Ref {
+ name: Name::new("A")?,
+ },
+ Schema::Ref {
+ name: Name::new("B")?,
+ },
+ ])?),
order: RecordFieldOrder::Ignore,
position: 0,
custom_attributes: Default::default(),
@@ -2327,15 +2321,12 @@ mod tests {
doc: None,
default: Some(Value::Null),
aliases: None,
- schema: Schema::Union(
- UnionSchema::new(vec![
- Schema::Null,
- Schema::Ref {
- name: Name::new("A")?,
- },
- ])
- ?,
- ),
+ schema: Schema::Union(UnionSchema::new(vec![
+ Schema::Null,
+ Schema::Ref {
+ name: Name::new("A")?,
+ },
+ ])?),
order: RecordFieldOrder::Ignore,
position: 0,
custom_attributes: Default::default(),
@@ -2362,8 +2353,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
let mut lookup = BTreeMap::new();
lookup.insert("a".to_owned(), 0);
@@ -2424,8 +2414,7 @@ mod tests {
}]
}
"#,
- )
- ?;
+ )?;
let mut lookup = BTreeMap::new();
lookup.insert("recordField".to_owned(), 0);
@@ -2608,8 +2597,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
let mut lookup = BTreeMap::new();
lookup.insert("value".to_owned(), 0);
@@ -2638,18 +2626,15 @@ mod tests {
doc: None,
default: None,
aliases: None,
- schema: Schema::Union(
- UnionSchema::new(vec![
- Schema::Null,
- Schema::Ref {
- name: Name {
- name: "LongList".to_owned(),
- namespace: None,
- },
+ schema: Schema::Union(UnionSchema::new(vec![
+ Schema::Null,
+ Schema::Ref {
+ name: Name {
+ name: "LongList".to_owned(),
+ namespace: None,
},
- ])
- ?,
- ),
+ },
+ ])?),
order: RecordFieldOrder::Ascending,
position: 1,
custom_attributes: Default::default(),
@@ -2680,8 +2665,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
let mut lookup = BTreeMap::new();
lookup.insert("value".to_owned(), 0);
@@ -2750,8 +2734,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
let mut lookup = BTreeMap::new();
lookup.insert("enum".to_owned(), 0);
@@ -2833,8 +2816,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
let mut lookup = BTreeMap::new();
lookup.insert("fixed".to_owned(), 0);
@@ -2966,8 +2948,7 @@ mod tests {
fn test_fixed_schema_with_documentation() -> TestResult {
let schema = Schema::parse_str(
r#"{"type": "fixed", "name": "test", "size": 16, "doc":
"FixedSchema documentation"}"#,
- )
- ?;
+ )?;
let expected = Schema::Fixed(FixedSchema {
name: Name::new("test")?,
@@ -2984,9 +2965,9 @@ mod tests {
#[test]
fn test_no_documentation() -> TestResult {
- let schema =
- Schema::parse_str(r#"{"type": "enum", "name": "Coin", "symbols":
["heads", "tails"]}"#)
- ?;
+ let schema = Schema::parse_str(
+ r#"{"type": "enum", "name": "Coin", "symbols": ["heads",
"tails"]}"#,
+ )?;
let doc = match schema {
Schema::Enum(EnumSchema { doc, .. }) => doc,
@@ -3001,7 +2982,7 @@ mod tests {
#[test]
fn test_documentation() -> TestResult {
let schema = Schema::parse_str(
- r#"{"type": "enum", "name": "Coin", "doc": "Some documentation",
"symbols": ["heads", "tails"]}"#
+ r#"{"type": "enum", "name": "Coin", "doc": "Some documentation",
"symbols": ["heads", "tails"]}"#,
)?;
let doc = match schema {
@@ -3074,8 +3055,7 @@ mod tests {
let schema = Schema::parse_str(r#"{"type": "int", "logicalType":
"date"}"#)?;
assert_eq!(schema, Schema::Date);
- let schema =
- Schema::parse_str(r#"{"type": "long", "logicalType":
"timestamp-micros"}"#)?;
+ let schema = Schema::parse_str(r#"{"type": "long", "logicalType":
"timestamp-micros"}"#)?;
assert_eq!(schema, Schema::TimestampMicros);
Ok(())
@@ -3085,11 +3065,13 @@ mod tests {
fn test_nullable_logical_type() -> TestResult {
let schema = Schema::parse_str(
r#"{"type": ["null", {"type": "long", "logicalType":
"timestamp-micros"}]}"#,
- )
- ?;
+ )?;
assert_eq!(
schema,
- Schema::Union(UnionSchema::new(vec![Schema::Null,
Schema::TimestampMicros])?)
+ Schema::Union(UnionSchema::new(vec![
+ Schema::Null,
+ Schema::TimestampMicros
+ ])?)
);
Ok(())
@@ -3129,8 +3111,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
let json = schema.canonical_form();
assert_eq!(
@@ -3985,8 +3966,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
if let Schema::Record(RecordSchema { ref aliases, .. }) = schema {
assert_avro_3512_aliases(aliases);
@@ -4011,8 +3991,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
if let Schema::Enum(EnumSchema { ref aliases, .. }) = schema {
assert_avro_3512_aliases(aliases);
@@ -4035,8 +4014,7 @@ mod tests {
"size" : 12
}
"#,
- )
- ?;
+ )?;
if let Schema::Fixed(FixedSchema { ref aliases, .. }) = schema {
assert_avro_3512_aliases(aliases);
@@ -4067,8 +4045,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
let value = serde_json::to_value(&schema)?;
let serialized = serde_json::to_string(&value)?;
@@ -4095,8 +4072,7 @@ mod tests {
]
}
"#,
- )
- ?;
+ )?;
let value = serde_json::to_value(&schema)?;
let serialized = serde_json::to_string(&value)?;
@@ -4121,8 +4097,7 @@ mod tests {
"size" : 12
}
"#,
- )
- ?;
+ )?;
let value = serde_json::to_value(&schema)?;
let serialized = serde_json::to_string(&value)?;
@@ -4273,8 +4248,7 @@ mod tests {
.to_owned()
.replace("{{{}}}", CUSTOM_ATTRS_SUFFIX)
.as_str(),
- )
- ?;
+ )?;
assert_eq!(
schema.custom_attributes(),
@@ -4319,8 +4293,7 @@ mod tests {
"#,
);
- let schema =
- Schema::parse_str(schema_str.replace("{{{}}}",
CUSTOM_ATTRS_SUFFIX).as_str())?;
+ let schema = Schema::parse_str(schema_str.replace("{{{}}}",
CUSTOM_ATTRS_SUFFIX).as_str())?;
match schema {
Schema::Record(RecordSchema { name, fields, .. }) => {
@@ -4671,8 +4644,7 @@ mod tests {
let datum = crate::to_avro_datum(&writer_schema, avro_value)?;
let mut x = &datum[..];
let reader_schema = Schema::parse_str(reader_schema)?;
- let deser_value =
- crate::from_avro_datum(&writer_schema, &mut x,
Some(&reader_schema))?;
+ let deser_value = crate::from_avro_datum(&writer_schema, &mut x,
Some(&reader_schema))?;
match deser_value {
types::Value::Record(fields) => {
assert_eq!(fields.len(), 2);
diff --git a/lang/rust/avro/src/schema_compatibility.rs
b/lang/rust/avro/src/schema_compatibility.rs
index dcd70f2b1..2fd50a5bb 100644
--- a/lang/rust/avro/src/schema_compatibility.rs
+++ b/lang/rust/avro/src/schema_compatibility.rs
@@ -326,8 +326,8 @@ impl SchemaCompatibility {
#[cfg(test)]
mod tests {
- use apache_avro_test_helper::TestResult;
use super::*;
+ use apache_avro_test_helper::TestResult;
fn int_array_schema() -> Schema {
Schema::parse_str(r#"{"type":"array", "items":"int"}"#).unwrap()
diff --git a/lang/rust/avro/src/ser.rs b/lang/rust/avro/src/ser.rs
index a2567f64f..0556dc28e 100644
--- a/lang/rust/avro/src/ser.rs
+++ b/lang/rust/avro/src/ser.rs
@@ -489,10 +489,10 @@ pub fn to_value<S: Serialize>(value: S) -> Result<Value,
Error> {
#[cfg(test)]
mod tests {
use super::*;
+ use apache_avro_test_helper::TestResult;
use pretty_assertions::assert_eq;
use serde::{Deserialize, Serialize};
use std::sync::atomic::Ordering;
- use apache_avro_test_helper::TestResult;
#[derive(Debug, Deserialize, Serialize, Clone)]
struct Test {
diff --git a/lang/rust/avro/src/types.rs b/lang/rust/avro/src/types.rs
index e8d4d8774..d5b00b719 100644
--- a/lang/rust/avro/src/types.rs
+++ b/lang/rust/avro/src/types.rs
@@ -1028,10 +1028,12 @@ mod tests {
schema::{Name, RecordField, RecordFieldOrder, Schema, UnionSchema},
types::Value,
};
- use apache_avro_test_helper::logger::{assert_logged, assert_not_logged};
+ use apache_avro_test_helper::{
+ logger::{assert_logged, assert_not_logged},
+ TestResult,
+ };
use pretty_assertions::assert_eq;
use uuid::Uuid;
- use apache_avro_test_helper::TestResult;
#[test]
fn validate() -> TestResult {
@@ -1336,9 +1338,7 @@ mod tests {
doc: None,
default: Some(JsonValue::Null),
aliases: None,
- schema: Schema::Union(
- UnionSchema::new(vec![Schema::Null, Schema::Int])?,
- ),
+ schema: Schema::Union(UnionSchema::new(vec![Schema::Null,
Schema::Int])?),
order: RecordFieldOrder::Ascending,
position: 2,
custom_attributes: Default::default(),
@@ -1498,14 +1498,11 @@ Field with name '"b"' is not a member of the map
items"#,
#[test]
fn resolve_decimal_bytes() -> TestResult {
let value = Value::Decimal(Decimal::from(vec![1, 2]));
- value
- .clone()
- .resolve(&Schema::Decimal(DecimalSchema {
- precision: 10,
- scale: 4,
- inner: Box::new(Schema::Bytes),
- }))
- ?;
+ value.clone().resolve(&Schema::Decimal(DecimalSchema {
+ precision: 10,
+ scale: 4,
+ inner: Box::new(Schema::Bytes),
+ }))?;
assert!(value.resolve(&Schema::String).is_err());
Ok(())
@@ -1657,8 +1654,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let value = Value::Record(vec![(
"event".to_string(),
@@ -1723,8 +1719,7 @@ Field with name '"b"' is not a member of the map items"#,
JsonValue::String("test_enum".into())
);
assert_eq!(
- JsonValue::try_from(Value::Union(1,
Box::new(Value::String("test_enum".into()))))
- ?,
+ JsonValue::try_from(Value::Union(1,
Box::new(Value::String("test_enum".into()))))?,
JsonValue::String("test_enum".into())
);
assert_eq!(
@@ -1732,8 +1727,7 @@ Field with name '"b"' is not a member of the map items"#,
Value::Int(1),
Value::Int(2),
Value::Int(3)
- ]))
- ?,
+ ]))?,
JsonValue::Array(vec![
JsonValue::Number(1.into()),
JsonValue::Number(2.into()),
@@ -1749,8 +1743,7 @@ Field with name '"b"' is not a member of the map items"#,
]
.into_iter()
.collect()
- ))
- ?,
+ ))?,
JsonValue::Object(
vec![
("v1".to_string(), JsonValue::Number(1.into())),
@@ -1766,8 +1759,7 @@ Field with name '"b"' is not a member of the map items"#,
("v1".to_string(), Value::Int(1)),
("v2".to_string(), Value::Int(2)),
("v3".to_string(), Value::Int(3))
- ]))
- ?,
+ ]))?,
JsonValue::Object(
vec![
("v1".to_string(), JsonValue::Number(1.into())),
@@ -1809,8 +1801,7 @@ Field with name '"b"' is not a member of the map items"#,
assert_eq!(
JsonValue::try_from(Value::Duration(
[1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8, 11u8,
12u8].into()
- ))
- ?,
+ ))?,
JsonValue::Array(vec![
JsonValue::Number(1.into()),
JsonValue::Number(2.into()),
@@ -1827,10 +1818,9 @@ Field with name '"b"' is not a member of the map items"#,
])
);
assert_eq!(
- JsonValue::try_from(Value::Uuid(
- Uuid::parse_str("936DA01F-9ABD-4D9D-80C7-02AF85C822A8")?
- ))
- ?,
+ JsonValue::try_from(Value::Uuid(Uuid::parse_str(
+ "936DA01F-9ABD-4D9D-80C7-02AF85C822A8"
+ )?))?,
JsonValue::String("936da01f-9abd-4d9d-80c7-02af85c822a8".into())
);
@@ -1862,8 +1852,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![("z".into(), Value::Int(6))]);
@@ -1906,8 +1895,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![("z".into(), Value::Int(6))]);
@@ -1953,8 +1941,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![("z".into(), Value::Int(6))]);
@@ -2004,8 +1991,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![(
@@ -2050,8 +2036,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![("z".into(), Value::Int(6))]);
@@ -2094,8 +2079,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let inner_value1 = Value::Record(vec![("z".into(), Value::Int(3))]);
let inner_value2 = Value::Record(vec![("z".into(), Value::Int(6))]);
@@ -2407,8 +2391,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let inner_value_right = Value::Record(vec![("z".into(),
Value::Int(3))]);
let inner_value_wrong1 = Value::Record(vec![("z".into(),
Value::Null)]);
@@ -2486,8 +2469,7 @@ Field with name '"b"' is not a member of the map items"#,
}
]
}"#,
- )
- ?;
+ )?;
let test_inner = TestInner { z: 3 };
let test_outer1 = TestRefSchemaStruct1 {
@@ -2691,17 +2673,17 @@ Field with name '"b"' is not a member of the map
items"#,
}
#[test]
- fn test_avro_3688_field_b_not_set()-> TestResult {
+ fn test_avro_3688_field_b_not_set() -> TestResult {
avro_3688_schema_resolution_panic(false)
}
#[test]
- fn test_avro_3688_field_b_set()-> TestResult {
+ fn test_avro_3688_field_b_set() -> TestResult {
avro_3688_schema_resolution_panic(true)
}
#[test]
- fn test_avro_3764_use_resolve_schemata() -> TestResult {
+ fn test_avro_3764_use_resolve_schemata() -> TestResult {
let referenced_schema =
r#"{"name": "enumForReference", "type": "enum", "symbols": ["A",
"B"]}"#;
let main_schema = r#"{"name": "recordWithReference", "type": "record",
"fields": [{"name": "reference", "type": "enumForReference"}]}"#;
@@ -2721,9 +2703,7 @@ Field with name '"b"' is not a member of the map items"#,
let main_schema = schemas.get(0).unwrap();
let schemata: Vec<_> = schemas.iter().skip(1).collect();
- let resolve_result = avro_value
- .clone()
- .resolve_schemata(main_schema, schemata);
+ let resolve_result = avro_value.clone().resolve_schemata(main_schema,
schemata);
assert!(
resolve_result.is_ok(),
diff --git a/lang/rust/avro/src/util.rs b/lang/rust/avro/src/util.rs
index 5ce901ed4..2ea134c77 100644
--- a/lang/rust/avro/src/util.rs
+++ b/lang/rust/avro/src/util.rs
@@ -187,8 +187,8 @@ pub(crate) fn is_human_readable() -> bool {
#[cfg(test)]
mod tests {
use super::*;
- use pretty_assertions::assert_eq;
use apache_avro_test_helper::TestResult;
+ use pretty_assertions::assert_eq;
#[test]
fn test_zigzag() {
diff --git a/lang/rust/avro/tests/io.rs b/lang/rust/avro/tests/io.rs
index 7c3d5e961..b835fe7af 100644
--- a/lang/rust/avro/tests/io.rs
+++ b/lang/rust/avro/tests/io.rs
@@ -17,10 +17,10 @@
//! Port of
https://github.com/apache/avro/blob/release-1.9.1/lang/py/test/test_io.py
use apache_avro::{from_avro_datum, to_avro_datum, types::Value, Error, Schema};
+use apache_avro_test_helper::TestResult;
use lazy_static::lazy_static;
use pretty_assertions::assert_eq;
use std::io::Cursor;
-use apache_avro_test_helper::TestResult;
lazy_static! {
static ref SCHEMAS_TO_VALIDATE: Vec<(&'static str, Value)> = vec![
@@ -316,7 +316,8 @@ fn test_type_exception() -> Result<(), String> {
]
}
"#,
- ).unwrap();
+ )
+ .unwrap();
let datum_to_write = Value::Record(vec![
("E".to_string(), Value::Int(5)),
("F".to_string(), Value::String(String::from("Bad"))),
diff --git a/lang/rust/avro/tests/schema.rs b/lang/rust/avro/tests/schema.rs
index 46292daea..cf1f75e76 100644
--- a/lang/rust/avro/tests/schema.rs
+++ b/lang/rust/avro/tests/schema.rs
@@ -701,8 +701,7 @@ fn test_equivalence_after_round_trip() -> TestResult {
init();
for (raw_schema, _) in VALID_EXAMPLES.iter() {
let original_schema = Schema::parse_str(raw_schema)?;
- let round_trip_schema =
- Schema::parse_str(original_schema.canonical_form().as_str())?;
+ let round_trip_schema =
Schema::parse_str(original_schema.canonical_form().as_str())?;
assert_eq!(original_schema, round_trip_schema);
}
Ok(())
@@ -992,8 +991,7 @@ fn test_parse_list_multiple_dependencies() -> TestResult {
]
}"#;
- let parsed =
- Schema::parse_list(&[schema_a_str, schema_b_str, schema_c_str])?;
+ let parsed = Schema::parse_list(&[schema_a_str, schema_b_str,
schema_c_str])?;
let schema_strs = vec![schema_a_str, schema_b_str, schema_c_str];
for schema_str_perm in permutations(&schema_strs) {
let schema_str_perm: Vec<&str> = schema_str_perm.iter().map(|s|
**s).collect();
@@ -1033,8 +1031,7 @@ fn test_parse_list_shared_dependency() -> TestResult {
]
}"#;
- let parsed =
- Schema::parse_list(&[schema_a_str, schema_b_str, schema_c_str])?;
+ let parsed = Schema::parse_list(&[schema_a_str, schema_b_str,
schema_c_str])?;
let schema_strs = vec![schema_a_str, schema_b_str, schema_c_str];
for schema_str_perm in permutations(&schema_strs) {
let schema_str_perm: Vec<&str> = schema_str_perm.iter().map(|s|
**s).collect();
@@ -1200,8 +1197,7 @@ fn test_avro_3452_parse_json_without_name_field() ->
TestResult {
fn test_fullname_fullname_namespace_and_default_namespace_specified() ->
TestResult {
init();
let name: Name =
- serde_json::from_str(r#"{"name": "a.b.c.d", "namespace": "o.a.a",
"aliases": null}"#)
- ?;
+ serde_json::from_str(r#"{"name": "a.b.c.d", "namespace": "o.a.a",
"aliases": null}"#)?;
assert_eq!(&name.name, "d");
assert_eq!(name.namespace, Some("a.b.c".to_owned()));
let fullname = name.fullname(Some("o.a.h".into()));
@@ -1320,8 +1316,7 @@ fn test_record_schema_with_cyclic_references() ->
TestResult {
}]
}
"#,
- )
- ?;
+ )?;
let mut datum = Record::new(&schema).unwrap();
datum.put(
diff --git a/lang/rust/avro/tests/shared.rs b/lang/rust/avro/tests/shared.rs
index ab85604e5..db54ce3ac 100644
--- a/lang/rust/avro/tests/shared.rs
+++ b/lang/rust/avro/tests/shared.rs
@@ -16,6 +16,7 @@
// under the License.
use apache_avro::{types::Value, Codec, Reader, Schema, Writer};
+use apache_avro_test_helper::TestResult;
use std::{
fmt,
fs::{DirEntry, File, ReadDir},
@@ -23,7 +24,6 @@ use std::{
path::Path,
slice::Iter,
};
-use apache_avro_test_helper::TestResult;
const ROOT_DIRECTORY: &str = "../../../share/test/data/schemas";
diff --git a/lang/rust/avro_test_helper/src/lib.rs
b/lang/rust/avro_test_helper/src/lib.rs
index 545bccc89..e2ab29eff 100644
--- a/lang/rust/avro_test_helper/src/lib.rs
+++ b/lang/rust/avro_test_helper/src/lib.rs
@@ -51,7 +51,7 @@ pub enum TestError {}
/// A converter of any error into [TestError].
/// It is used to print better error messages in the tests.
-/// Borrowed from
https://bluxte.net/musings/2023/01/08/improving_failure_messages_rust_tests/
+/// Borrowed from
<https://bluxte.net/musings/2023/01/08/improving_failure_messages_rust_tests/>
impl<Err: std::fmt::Display> From<Err> for TestError {
#[track_caller]
fn from(err: Err) -> Self {