From 55ddb983a18350ae20b40f9d42af99500db83eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Thu, 19 Oct 2023 12:12:34 +0200 Subject: [PATCH] format: applied cargo clippy --fix --- aw-datastore/src/datastore.rs | 2 +- aw-datastore/tests/datastore.rs | 6 +++--- aw-query/tests/query.rs | 14 +++++++------- aw-server/src/endpoints/util.rs | 6 +++--- aw-transform/src/classify.rs | 12 ++++++------ 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/aw-datastore/src/datastore.rs b/aw-datastore/src/datastore.rs index 8d6692a1..04c60fcb 100644 --- a/aw-datastore/src/datastore.rs +++ b/aw-datastore/src/datastore.rs @@ -909,7 +909,7 @@ impl DatastoreInstance { } }; - match stmt.query_row([key], |row| Ok(row.get(1)?)) { + match stmt.query_row([key], |row| row.get(1)) { Ok(result) => Ok(result), Err(err) => match err { rusqlite::Error::QueryReturnedNoRows => { diff --git a/aw-datastore/tests/datastore.rs b/aw-datastore/tests/datastore.rs index 746c8e85..1290d697 100644 --- a/aw-datastore/tests/datastore.rs +++ b/aw-datastore/tests/datastore.rs @@ -169,7 +169,7 @@ mod datastore_tests { // Get all events let fetched_events_all = ds.get_events(&bucket.id, None, None, None).unwrap(); - let expected_fetched_events = vec![&e2, &e1]; + let expected_fetched_events = [&e2, &e1]; assert_eq!(fetched_events_all.len(), 2); for i in 0..fetched_events_all.len() { let expected = &expected_fetched_events[i]; @@ -268,7 +268,7 @@ mod datastore_tests { // Get all events let fetched_events_all = ds.get_events(&bucket.id, None, None, None).unwrap(); - let expected_fetched_events = vec![&e2, &e1]; + let expected_fetched_events = [&e2, &e1]; assert_eq!(fetched_events_all.len(), 2); for i in 0..fetched_events_all.len() { let expected = &expected_fetched_events[i]; @@ -286,7 +286,7 @@ mod datastore_tests { // Get all events let fetched_events_all = ds.get_events(&bucket.id, None, None, None).unwrap(); - let expected_fetched_events = vec![e2]; + let expected_fetched_events = [e2]; assert_eq!(fetched_events_all.len(), 1); for i in 0..fetched_events_all.len() { let expected = &expected_fetched_events[i]; diff --git a/aw-query/tests/query.rs b/aw-query/tests/query.rs index 71969aaa..2bb551c1 100644 --- a/aw-query/tests/query.rs +++ b/aw-query/tests/query.rs @@ -104,7 +104,7 @@ mod query_tests { let code = String::from("True;False;a=True;return True;"); match aw_query::query(&code, &interval, &ds).unwrap() { - aw_query::DataType::Bool(b) => assert_eq!(b, true), + aw_query::DataType::Bool(b) => assert!(b), ref data => panic!("Wrong datatype, {data:?}"), }; } @@ -129,42 +129,42 @@ mod query_tests { // number comparison true let code = String::from("return 1==1;"); match aw_query::query(&code, &interval, &ds).unwrap() { - aw_query::DataType::Bool(b) => assert_eq!(b, true), + aw_query::DataType::Bool(b) => assert!(b), ref data => panic!("Wrong datatype, {data:?}"), }; // number comparison false let code = String::from("return 2==1;"); match aw_query::query(&code, &interval, &ds).unwrap() { - aw_query::DataType::Bool(b) => assert_eq!(b, false), + aw_query::DataType::Bool(b) => assert!(!b), ref data => panic!("Wrong datatype, {data:?}"), }; // string comparison true let code = String::from(r#"return "a"=="a";"#); match aw_query::query(&code, &interval, &ds).unwrap() { - aw_query::DataType::Bool(b) => assert_eq!(b, true), + aw_query::DataType::Bool(b) => assert!(b), ref data => panic!("Wrong datatype, {data:?}"), }; // string comparison false let code = String::from(r#"return "a"=="b";"#); match aw_query::query(&code, &interval, &ds).unwrap() { - aw_query::DataType::Bool(b) => assert_eq!(b, false), + aw_query::DataType::Bool(b) => assert!(!b), ref data => panic!("Wrong datatype, {data:?}"), }; // bool comparison true let code = String::from("return True==True;"); match aw_query::query(&code, &interval, &ds).unwrap() { - aw_query::DataType::Bool(b) => assert_eq!(b, true), + aw_query::DataType::Bool(b) => assert!(b), ref data => panic!("Wrong datatype, {data:?}"), }; // bool comparison false let code = String::from("return False==True;"); match aw_query::query(&code, &interval, &ds).unwrap() { - aw_query::DataType::Bool(b) => assert_eq!(b, false), + aw_query::DataType::Bool(b) => assert!(!b), ref data => panic!("Wrong datatype, {data:?}"), }; diff --git a/aw-server/src/endpoints/util.rs b/aw-server/src/endpoints/util.rs index def7b0ae..fdf4a992 100644 --- a/aw-server/src/endpoints/util.rs +++ b/aw-server/src/endpoints/util.rs @@ -69,9 +69,9 @@ impl<'r> Responder<'r, 'static> for BucketsExportRocket { use aw_datastore::DatastoreError; -impl Into for DatastoreError { - fn into(self) -> HttpErrorJson { - match self { +impl From for HttpErrorJson { + fn from(val: DatastoreError) -> Self { + match val { DatastoreError::NoSuchBucket(bucket_id) => HttpErrorJson::new( Status::NotFound, format!("The requested bucket '{bucket_id}' does not exist"), diff --git a/aw-transform/src/classify.rs b/aw-transform/src/classify.rs index 28fd4fbb..114650d6 100644 --- a/aw-transform/src/classify.rs +++ b/aw-transform/src/classify.rs @@ -137,12 +137,12 @@ fn test_rule() { let rule_from_regex = Rule::from(Regex::new("test").unwrap()); let rule_from_new = Rule::Regex(RegexRule::new("test", false).unwrap()); let rule_none = Rule::None; - assert_eq!(rule_from_regex.matches(&e_match), true); - assert_eq!(rule_from_new.matches(&e_match), true); - assert_eq!(rule_from_regex.matches(&e_no_match), false); - assert_eq!(rule_from_new.matches(&e_no_match), false); + assert!(rule_from_regex.matches(&e_match)); + assert!(rule_from_new.matches(&e_match)); + assert!(!rule_from_regex.matches(&e_no_match)); + assert!(!rule_from_new.matches(&e_no_match)); - assert_eq!(rule_none.matches(&e_match), false); + assert!(!rule_none.matches(&e_match)); } #[test] @@ -154,7 +154,7 @@ fn test_rule_lookahead() { .insert("test".into(), serde_json::json!("testing lookahead")); let rule_from_regex = Rule::from(Regex::new("testing (?!lookahead)").unwrap()); - assert_eq!(rule_from_regex.matches(&e_match), false); + assert!(!rule_from_regex.matches(&e_match)); } #[test]