diff --git a/src/hashed_text.rs b/src/hashed_text.rs index 9257adc..d07576a 100644 --- a/src/hashed_text.rs +++ b/src/hashed_text.rs @@ -20,7 +20,7 @@ impl Ext for HashedTextExtImpl where Db: Postgres impl HashedTextExt for HashedTextExtImpl where Db: Postgres { fn matches>(&self, this: &HashedText, other: S) -> Result> { - static QUERY: &'static str = + static QUERY: &str = "select public.hashed_text_matches($1, public.hashed_text_of_string($2))"; self.0 @@ -31,11 +31,11 @@ impl HashedTextExt for HashedTextExtImpl where Db: Postgres #[cfg(test)] mod test { - use std::any::Any; - use std::panic::AssertUnwindSafe; + + - use postgres::types::private::BytesMut; - use postgres::types::{FromSql, ToSql, Type}; + + use postgres::types::{Type}; use super::{HashedText, HashedTextExt, HashedTextExtImpl}; use crate::postgres::test::{from_sql_owned, Client, Row}; @@ -47,7 +47,7 @@ mod test { assert_eq!(q.unwrap_str(), "select public.hashed_text_matches($1, public.hashed_text_of_string($2))"); assert_eq!(from_sql_owned::(ps[1]), String::from("XXX")); - Ok(Row::new(vec![("", Type::BOOL)]).value(Type::BOOL, from_sql_owned::(ps[0]) == String::from("foo"))) + Ok(Row::new(vec![("", Type::BOOL)]).value(Type::BOOL, from_sql_owned::(ps[0]) == *"foo")) }), ..Client::default() }; diff --git a/src/main.rs b/src/main.rs index cab9a66..d4180ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,18 @@ -use hashed_text::HashedTextExt; + use toad::config::Config; use toad::net::Addrd; use toad::platform::Platform as _; use toad::req::Req; use toad::resp::Resp; -use toad::std::dtls; + mod app; mod hashed_text; mod postgres; mod repo; mod user; -use repo::Repo; -use user::UserRepo; + + #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] pub struct Email(String); @@ -32,12 +32,12 @@ fn handle_request(req: Addrd>) -> Result>, String> .map_err(|e| format!("{e:?}")) .unwrap_or(None) .unwrap_or(""); - let mut path_segments = path.split("/").peekable(); + let mut path_segments = path.split('/').peekable(); if path_segments.peek() == Some(&"users") { let mut path_segments = path_segments.clone(); path_segments.next(); - let id = path_segments.next(); + let _id = path_segments.next(); } Ok(req.map(|r| Resp::for_request(&r).unwrap())) diff --git a/src/postgres.rs b/src/postgres.rs index 0dc7d2f..bbc5cf2 100644 --- a/src/postgres.rs +++ b/src/postgres.rs @@ -1,8 +1,8 @@ -use std::ops::{Deref, DerefMut}; +use std::ops::{DerefMut}; use std::pin::Pin; -use std::sync::{Mutex, MutexGuard, TryLockError}; +use std::sync::{Mutex, MutexGuard}; -use rand::{Rng, SeedableRng}; +use rand::{Rng}; pub type DbError = <::Client as postgres::GenericClient>::Error; @@ -374,15 +374,15 @@ pub mod test { fn commit(mut self) -> Result<(), E> { let mut f = Client::::default().commit; std::mem::swap(&mut self.commit, &mut f); - let res = f(self); - res + + f(self) } fn rollback(mut self) -> Result<(), E> { let mut f = Client::::default().rollback; std::mem::swap(&mut self.commit, &mut f); - let res = f(self); - res + + f(self) } }