style(rust): Format all Rust code with rustfmt

Change-Id: Iab7e00cc26a4f9727d3ab98691ef379921a33052
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5240
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Vincent Ambo 2022-02-07 18:49:59 +03:00 committed by tazjin
parent 3318982f81
commit 3d8ee62087
42 changed files with 1253 additions and 876 deletions

View file

@ -20,14 +20,14 @@
//! data into whatever format is needed by the templates and rendering
//! them.
use crate::errors::*;
use crate::models::*;
use actix::prelude::*;
use askama::Template;
use crate::errors::*;
use std::fmt;
use md5;
use crate::models::*;
use chrono::prelude::{DateTime, Utc};
use comrak::{ComrakOptions, markdown_to_html};
use comrak::{markdown_to_html, ComrakOptions};
use md5;
use std::fmt;
pub struct Renderer {
pub comrak: ComrakOptions,
@ -101,7 +101,9 @@ pub enum EditingMode {
}
impl Default for EditingMode {
fn default() -> EditingMode { EditingMode::NewThread }
fn default() -> EditingMode {
EditingMode::NewThread
}
}
/// This is the template used for rendering the new thread, edit post
@ -215,19 +217,22 @@ pub fn index_page(threads: Vec<ThreadIndex>) -> Result<String> {
// Render the page of a given thread.
pub fn thread_page(user: i32, thread: Thread, posts: Vec<SimplePost>) -> Result<String> {
let posts = posts.into_iter().map(|post| {
let editable = user != 1 && post.user_id == user;
let posts = posts
.into_iter()
.map(|post| {
let editable = user != 1 && post.user_id == user;
let comrak = ComrakOptions::default(); // TODO(tazjin): cheddar
RenderablePost {
id: post.id,
body: markdown_to_html(&post.body, &comrak),
posted: FormattedDate(post.posted),
author_name: post.author_name.clone(),
author_gravatar: md5_hex(post.author_email.as_bytes()),
editable,
}
}).collect();
let comrak = ComrakOptions::default(); // TODO(tazjin): cheddar
RenderablePost {
id: post.id,
body: markdown_to_html(&post.body, &comrak),
posted: FormattedDate(post.posted),
author_name: post.author_name.clone(),
author_gravatar: md5_hex(post.author_email.as_bytes()),
editable,
}
})
.collect();
let renderable = RenderableThreadPage {
posts,