From 3ff86c399492c09d2f8d8ad8f1f9f544ab54ecc0 Mon Sep 17 00:00:00 2001 From: Jason Ribble Date: Wed, 9 Oct 2024 10:36:43 -0700 Subject: [PATCH] style: lint with clippy --- src/db/connection.rs | 1 + src/models/contact.rs | 6 ++++++ src/models/metadata.rs | 2 +- src/utils/validation.rs | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/db/connection.rs b/src/db/connection.rs index 358201c..a831c87 100644 --- a/src/db/connection.rs +++ b/src/db/connection.rs @@ -5,6 +5,7 @@ pub struct Connection { } impl Connection { + #[must_use] pub fn new(pool: SqlitePool) -> Self { Self { sqlite_pool: Arc::new(pool), diff --git a/src/models/contact.rs b/src/models/contact.rs index f850904..d838f1b 100644 --- a/src/models/contact.rs +++ b/src/models/contact.rs @@ -42,6 +42,9 @@ pub struct Construct { pub update: Update, } impl Construct { + /// # Errors + /// + /// This errors if there is an invalid email or phone number pub fn new( id: i64, first_name: Option, @@ -90,6 +93,9 @@ impl Construct { } impl Contact { + /// # Errors + /// + /// This errors if there is an invalid email or phone number pub fn new( first_name: &str, last_name: &str, diff --git a/src/models/metadata.rs b/src/models/metadata.rs index e2d1957..4c56117 100644 --- a/src/models/metadata.rs +++ b/src/models/metadata.rs @@ -14,7 +14,7 @@ pub struct Metadata { } impl Metadata { - #[allow(dead_code)] + #[must_use] pub fn new(contact_id: i64) -> Self { let now = Utc::now(); diff --git a/src/utils/validation.rs b/src/utils/validation.rs index a51cde9..9deb9c4 100644 --- a/src/utils/validation.rs +++ b/src/utils/validation.rs @@ -7,6 +7,7 @@ fn is_valid_phone_number(phone: &str) -> bool { phone_regex.is_match(phone) } +#[must_use] pub fn is_not_valid_phone_number(phone_number: &str) -> bool { !is_valid_phone_number(phone_number) } @@ -17,6 +18,7 @@ fn is_valid_email(email: &str) -> bool { email_regex.is_match(email) } +#[must_use] pub fn is_not_valid_email(email: &str) -> bool { !is_valid_email(email) }