From 3deb07e6ee684ed49734318f6444e578dc84bfc5 Mon Sep 17 00:00:00 2001 From: tu6ge Date: Sun, 26 May 2024 08:58:44 +0800 Subject: [PATCH] style: fmt --- examples/string_custom.rs | 40 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/examples/string_custom.rs b/examples/string_custom.rs index b8566b0..56ead6a 100644 --- a/examples/string_custom.rs +++ b/examples/string_custom.rs @@ -64,7 +64,6 @@ pub fn establish_connection() -> PgConnection { PgConnection::establish("DATABASE_URL").unwrap() } - diesel::table! { inputs (email) { name -> Varchar, @@ -79,22 +78,25 @@ diesel::table! { struct UniqueEmail; impl StringRule for UniqueEmail { - type Message = String; - const NAME: &'static str = "unique_email"; - fn call(&mut self, data: &mut String) -> bool { - - use diesel::prelude::*; - use self::inputs::dsl::*; - //use self::models::*; - - let conn = &mut establish_connection(); - - let results = inputs.filter(email.eq(data.to_owned())).select(Input::as_select()).load(conn).unwrap(); - - results.len() == 0 - } + type Message = String; + const NAME: &'static str = "unique_email"; + fn call(&mut self, data: &mut String) -> bool { + use self::inputs::dsl::*; + use diesel::prelude::*; + //use self::models::*; - fn message(&self) -> Self::Message { - format!("email is existing") - } -} \ No newline at end of file + let conn = &mut establish_connection(); + + let results = inputs + .filter(email.eq(data.to_owned())) + .select(Input::as_select()) + .load(conn) + .unwrap(); + + results.len() == 0 + } + + fn message(&self) -> Self::Message { + format!("email is existing") + } +}