From 79b041f81f6d66e6f40ffc58e00af4337d6a50a0 Mon Sep 17 00:00:00 2001 From: PSeitz Date: Tue, 13 Feb 2024 05:56:31 +0100 Subject: [PATCH] clippy (#2314) --- src/directory/mmap_directory.rs | 1 + src/indexer/mod.rs | 5 ++--- src/schema/document/de.rs | 8 ++++---- src/schema/document/se.rs | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index e02d4f8ddd..f953f46896 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -479,6 +479,7 @@ impl Directory for MmapDirectory { let file: File = OpenOptions::new() .write(true) .create(true) //< if the file does not exist yet, create it. + .truncate(false) .open(full_path) .map_err(LockError::wrap_io_error)?; if lock.is_blocking { diff --git a/src/indexer/mod.rs b/src/indexer/mod.rs index ec84c37ae2..5b43a03301 100644 --- a/src/indexer/mod.rs +++ b/src/indexer/mod.rs @@ -406,11 +406,10 @@ mod tests_mmap { let searcher = reader.searcher(); - let fields_and_vals = vec![ - // Only way to address or it gets shadowed by `json.shadow` field + let fields_and_vals = [ ("json.shadow\u{1}val".to_string(), "a"), // Succeeds //("json.shadow.val".to_string(), "a"), // Fails - ("json.shadow.val".to_string(), "b"), // Succeeds + ("json.shadow.val".to_string(), "b"), ]; let query_parser = QueryParser::for_index(&index, vec![]); diff --git a/src/schema/document/de.rs b/src/schema/document/de.rs index 706f3b768e..9e56bc1cfb 100644 --- a/src/schema/document/de.rs +++ b/src/schema/document/de.rs @@ -889,7 +889,7 @@ mod tests { #[test] fn test_array_serialize() { - let elements = vec![serde_json::Value::Null, serde_json::Value::Null]; + let elements = [serde_json::Value::Null, serde_json::Value::Null]; let result = serialize_value(ReferenceValue::Array(elements.iter())); let value = deserialize_value(result); assert_eq!( @@ -900,7 +900,7 @@ mod tests { ]), ); - let elements = vec![ + let elements = [ serde_json::Value::String("Hello, world".into()), serde_json::Value::String("Some demo".into()), ]; @@ -914,12 +914,12 @@ mod tests { ]), ); - let elements = vec![]; + let elements = []; let result = serialize_value(ReferenceValue::Array(elements.iter())); let value = deserialize_value(result); assert_eq!(value, crate::schema::OwnedValue::Array(vec![])); - let elements = vec![ + let elements = [ serde_json::Value::Null, serde_json::Value::String("Hello, world".into()), serde_json::Value::Number(12345.into()), diff --git a/src/schema/document/se.rs b/src/schema/document/se.rs index 10e0657e0c..8acffb36b7 100644 --- a/src/schema/document/se.rs +++ b/src/schema/document/se.rs @@ -453,7 +453,7 @@ mod tests { #[test] fn test_array_serialize() { - let elements = vec![serde_json::Value::Null, serde_json::Value::Null]; + let elements = [serde_json::Value::Null, serde_json::Value::Null]; let result = serialize_value(ReferenceValue::Array(elements.iter())); let expected = binary_repr!( collection type_codes::ARRAY_CODE, @@ -466,7 +466,7 @@ mod tests { "Expected serialized value to match the binary representation" ); - let elements = vec![ + let elements = [ serde_json::Value::String("Hello, world".into()), serde_json::Value::String("Some demo".into()), ]; @@ -482,7 +482,7 @@ mod tests { "Expected serialized value to match the binary representation" ); - let elements = vec![]; + let elements = []; let result = serialize_value(ReferenceValue::Array(elements.iter())); let expected = binary_repr!( collection type_codes::ARRAY_CODE, @@ -493,7 +493,7 @@ mod tests { "Expected serialized value to match the binary representation" ); - let elements = vec![ + let elements = [ serde_json::Value::Null, serde_json::Value::String("Hello, world".into()), serde_json::Value::Number(12345.into()),