Skip to content

Commit

Permalink
style: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tu6ge committed May 26, 2024
1 parent 6f9a4c4 commit 3deb07e
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions examples/string_custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ pub fn establish_connection() -> PgConnection {
PgConnection::establish("DATABASE_URL").unwrap()
}


diesel::table! {
inputs (email) {
name -> Varchar,
Expand All @@ -79,22 +78,25 @@ diesel::table! {
struct UniqueEmail;

Check warning on line 78 in examples/string_custom.rs

View workflow job for this annotation

GitHub Actions / test

struct `UniqueEmail` is never constructed

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")
}
}
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")
}
}

0 comments on commit 3deb07e

Please sign in to comment.