From 5b792cd7e5faac4e7107b28e504c56cac88afb81 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Fri, 8 Jul 2022 18:39:39 -0700 Subject: [PATCH] cargo fmt --- src/comment.rs | 2 +- src/database.rs | 6 +++--- src/main.rs | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/comment.rs b/src/comment.rs index 60f97ad..66b139e 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -1,5 +1,5 @@ -use serde::{Deserialize, Serialize}; use chrono::NaiveDateTime; +use serde::{Deserialize, Serialize}; // Master comment type that is stored in database pub struct Comment { diff --git a/src/database.rs b/src/database.rs index 457e621..760d267 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,6 +1,6 @@ -use rusqlite::{params, Connection, Result}; use crate::comment::{Comment, CommentSend}; use chrono::NaiveDateTime; +use rusqlite::{params, Connection, Result}; pub struct Database { conn: Connection, @@ -17,7 +17,7 @@ impl Database { text TEXT NOT NULL, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP )", - params![] + params![], )?; Ok(Self { conn }) } @@ -40,7 +40,7 @@ impl Database { })? .collect() } - + pub fn create_comment(&self, comment: &Comment) -> Result<()> { self.conn.execute( "INSERT INTO comment (author, email, text) VALUES (?1, ?2, ?3)", diff --git a/src/main.rs b/src/main.rs index ccc3b17..3721688 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; use std::sync::Mutex; struct AppState { - db: Mutex + db: Mutex, } #[get("/")] @@ -34,8 +34,8 @@ async fn post_comment(data: web::Data, bytes: web::Bytes) -> impl Resp }; db.create_comment(&comment.to_master()).unwrap(); HttpResponse::Ok() - }, - Err(_) => HttpResponse::BadRequest().into() + } + Err(_) => HttpResponse::BadRequest().into(), } } @@ -49,7 +49,7 @@ async fn main() -> Result<(), std::io::Error> { .service(post_comment) .app_data(state.clone()) }) - .bind(("127.0.0.1", 8080))? - .run() - .await + .bind(("127.0.0.1", 8080))? + .run() + .await }