You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/02/25 07:43:23 UTC

[avro] branch master updated: AVRO-3418: [Rust] Fix clippy errors for Rust 1.59.0

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 a4a0993  AVRO-3418: [Rust] Fix clippy errors for Rust 1.59.0
a4a0993 is described below

commit a4a0993a3eeb2f6a185a4314c50511037dadbac2
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Fri Feb 25 09:42:37 2022 +0200

    AVRO-3418: [Rust] Fix clippy errors for Rust 1.59.0
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
 lang/rust/src/decode.rs |  2 +-
 lang/rust/src/rabin.rs  |  2 +-
 lang/rust/src/reader.rs | 12 ++++--------
 lang/rust/src/writer.rs |  4 ++--
 4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/lang/rust/src/decode.rs b/lang/rust/src/decode.rs
index 70c1ba5..83ee68e 100644
--- a/lang/rust/src/decode.rs
+++ b/lang/rust/src/decode.rs
@@ -210,7 +210,7 @@ pub fn decode<R: Read>(schema: &Schema, reader: &mut R) -> AvroResult<Value> {
                             usize::try_from(index)
                                 .map_err(|e| Error::ConvertI64ToUsize(e, index))?,
                         )
-                        .ok_or_else(|| Error::GetUnionVariant {
+                        .ok_or(Error::GetUnionVariant {
                             index,
                             num_variants: variants.len(),
                         })?;
diff --git a/lang/rust/src/rabin.rs b/lang/rust/src/rabin.rs
index e1ede43..011a600 100644
--- a/lang/rust/src/rabin.rs
+++ b/lang/rust/src/rabin.rs
@@ -154,7 +154,7 @@ mod tests {
 
         for (s, fp) in data {
             hasher.update(s.as_bytes());
-            let result = LittleEndian::read_i64(&hasher.finalize_reset().to_vec());
+            let result = LittleEndian::read_i64(&hasher.finalize_reset());
             assert_eq!(*fp, result);
         }
     }
diff --git a/lang/rust/src/reader.rs b/lang/rust/src/reader.rs
index fb83e64..0b75e64 100644
--- a/lang/rust/src/reader.rs
+++ b/lang/rust/src/reader.rs
@@ -501,7 +501,7 @@ mod tests {
     #[test]
     fn test_reader_invalid_header() {
         let schema = Schema::parse_str(SCHEMA).unwrap();
-        let invalid = ENCODED.to_owned().into_iter().skip(1).collect::<Vec<u8>>();
+        let invalid = ENCODED.iter().copied().skip(1).collect::<Vec<u8>>();
         assert!(Reader::with_schema(&schema, &invalid[..]).is_err());
     }
 
@@ -509,8 +509,8 @@ mod tests {
     fn test_reader_invalid_block() {
         let schema = Schema::parse_str(SCHEMA).unwrap();
         let invalid = ENCODED
-            .to_owned()
-            .into_iter()
+            .iter()
+            .copied()
             .rev()
             .skip(19)
             .collect::<Vec<u8>>()
@@ -531,11 +531,7 @@ mod tests {
 
     #[test]
     fn test_reader_only_header() {
-        let invalid = ENCODED
-            .to_owned()
-            .into_iter()
-            .take(165)
-            .collect::<Vec<u8>>();
+        let invalid = ENCODED.iter().copied().take(165).collect::<Vec<u8>>();
         let reader = Reader::new(&invalid[..]).unwrap();
         for value in reader {
             assert!(value.is_err());
diff --git a/lang/rust/src/writer.rs b/lang/rust/src/writer.rs
index f8a4554..9aa8d7d 100644
--- a/lang/rust/src/writer.rs
+++ b/lang/rust/src/writer.rs
@@ -837,7 +837,7 @@ mod tests {
         let mut writer = Writer::new(&schema, Vec::new());
 
         writer
-            .add_user_metadata("stringKey".to_string(), "stringValue".to_string())
+            .add_user_metadata("stringKey".to_string(), String::from("stringValue"))
             .unwrap();
         writer
             .add_user_metadata("strKey".to_string(), "strValue")
@@ -871,7 +871,7 @@ mod tests {
         record.put("b", "foo");
         writer.append(record.clone()).unwrap();
 
-        match writer.add_user_metadata("stringKey".to_string(), "value2".to_string()) {
+        match writer.add_user_metadata("stringKey".to_string(), String::from("value2")) {
             Err(e @ Error::FileHeaderAlreadyWritten) => {
                 assert_eq!(e.to_string(), "The file metadata is already flushed.")
             }