From c51d9f9f8355c3ab05f30eb0041ee2acaa386975 Mon Sep 17 00:00:00 2001 From: Adrien Guillo Date: Tue, 17 Jan 2023 10:15:31 -0500 Subject: [PATCH] Fix some Clippy warnings --- benches/index-bench.rs | 12 ++++++------ examples/aggregation.rs | 6 +++--- src/aggregation/metric/mod.rs | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/benches/index-bench.rs b/benches/index-bench.rs index c6cf31b62..6318df359 100644 --- a/benches/index-bench.rs +++ b/benches/index-bench.rs @@ -34,7 +34,7 @@ pub fn hdfs_index_benchmark(c: &mut Criterion) { let index = Index::create_in_ram(schema.clone()); let index_writer = index.writer_with_num_threads(1, 100_000_000).unwrap(); for _ in 0..NUM_REPEATS { - for doc_json in HDFS_LOGS.trim().split("\n") { + for doc_json in HDFS_LOGS.trim().split('\n') { let doc = schema.parse_document(doc_json).unwrap(); index_writer.add_document(doc).unwrap(); } @@ -46,7 +46,7 @@ pub fn hdfs_index_benchmark(c: &mut Criterion) { let index = Index::create_in_ram(schema.clone()); let mut index_writer = index.writer_with_num_threads(1, 100_000_000).unwrap(); for _ in 0..NUM_REPEATS { - for doc_json in HDFS_LOGS.trim().split("\n") { + for doc_json in HDFS_LOGS.trim().split('\n') { let doc = schema.parse_document(doc_json).unwrap(); index_writer.add_document(doc).unwrap(); } @@ -59,7 +59,7 @@ pub fn hdfs_index_benchmark(c: &mut Criterion) { let index = Index::create_in_ram(schema_with_store.clone()); let index_writer = index.writer_with_num_threads(1, 100_000_000).unwrap(); for _ in 0..NUM_REPEATS { - for doc_json in HDFS_LOGS.trim().split("\n") { + for doc_json in HDFS_LOGS.trim().split('\n') { let doc = schema.parse_document(doc_json).unwrap(); index_writer.add_document(doc).unwrap(); } @@ -71,7 +71,7 @@ pub fn hdfs_index_benchmark(c: &mut Criterion) { let index = Index::create_in_ram(schema_with_store.clone()); let mut index_writer = index.writer_with_num_threads(1, 100_000_000).unwrap(); for _ in 0..NUM_REPEATS { - for doc_json in HDFS_LOGS.trim().split("\n") { + for doc_json in HDFS_LOGS.trim().split('\n') { let doc = schema.parse_document(doc_json).unwrap(); index_writer.add_document(doc).unwrap(); } @@ -85,7 +85,7 @@ pub fn hdfs_index_benchmark(c: &mut Criterion) { let json_field = dynamic_schema.get_field("json").unwrap(); let mut index_writer = index.writer_with_num_threads(1, 100_000_000).unwrap(); for _ in 0..NUM_REPEATS { - for doc_json in HDFS_LOGS.trim().split("\n") { + for doc_json in HDFS_LOGS.trim().split('\n') { let json_val: serde_json::Map = serde_json::from_str(doc_json).unwrap(); let doc = tantivy::doc!(json_field=>json_val); @@ -101,7 +101,7 @@ pub fn hdfs_index_benchmark(c: &mut Criterion) { let json_field = dynamic_schema.get_field("json").unwrap(); let mut index_writer = index.writer_with_num_threads(1, 100_000_000).unwrap(); for _ in 0..NUM_REPEATS { - for doc_json in HDFS_LOGS.trim().split("\n") { + for doc_json in HDFS_LOGS.trim().split('\n') { let json_val: serde_json::Map = serde_json::from_str(doc_json).unwrap(); let doc = tantivy::doc!(json_field=>json_val); diff --git a/examples/aggregation.rs b/examples/aggregation.rs index fbe412e8e..d7b763788 100644 --- a/examples/aggregation.rs +++ b/examples/aggregation.rs @@ -27,7 +27,7 @@ fn main() -> tantivy::Result<()> { let score_fieldtype = crate::schema::NumericOptions::default().set_fast(Cardinality::SingleValue); let highscore_field = schema_builder.add_f64_field("highscore", score_fieldtype.clone()); - let price_field = schema_builder.add_f64_field("price", score_fieldtype.clone()); + let price_field = schema_builder.add_f64_field("price", score_fieldtype); let schema = schema_builder.build(); @@ -112,7 +112,7 @@ fn main() -> tantivy::Result<()> { ], ..Default::default() }), - sub_aggregation: sub_agg_req_1.clone(), + sub_aggregation: sub_agg_req_1, }), )] .into_iter() @@ -123,7 +123,7 @@ fn main() -> tantivy::Result<()> { let searcher = reader.searcher(); let agg_res: AggregationResults = searcher.search(&term_query, &collector).unwrap(); - let res: Value = serde_json::to_value(&agg_res)?; + let res: Value = serde_json::to_value(agg_res)?; println!("{}", serde_json::to_string_pretty(&res)?); Ok(()) diff --git a/src/aggregation/metric/mod.rs b/src/aggregation/metric/mod.rs index 87fd64e45..0d1ad056d 100644 --- a/src/aggregation/metric/mod.rs +++ b/src/aggregation/metric/mod.rs @@ -80,12 +80,12 @@ mod tests { "price_stats": { "stats": { "field": "price" } }, "price_sum": { "sum": { "field": "price" } } }"#; - let aggregations: Aggregations = serde_json::from_str(&aggregations_json).unwrap(); + let aggregations: Aggregations = serde_json::from_str(aggregations_json).unwrap(); let collector = AggregationCollector::from_aggs(aggregations, None, index.schema()); let reader = index.reader().unwrap(); let searcher = reader.searcher(); let aggregations_res: AggregationResults = searcher.search(&AllQuery, &collector).unwrap(); - let aggregations_res_json = serde_json::to_value(&aggregations_res).unwrap(); + let aggregations_res_json = serde_json::to_value(aggregations_res).unwrap(); assert_eq!(aggregations_res_json["price_avg"]["value"], 2.5); assert_eq!(aggregations_res_json["price_count"]["value"], 6.0);