This commit is contained in:
+7
-4
@@ -14,6 +14,7 @@ use rocket_dyn_templates::Template;
|
||||
use rand::distributions::Uniform;
|
||||
use rand::Rng;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
@@ -26,6 +27,10 @@ use std::time::Duration;
|
||||
|
||||
const DB_FILENAME: &str = "db.dat";
|
||||
|
||||
lazy_static! {
|
||||
static ref EMPTY_MAP: HashMap<String, String> = HashMap::new();
|
||||
}
|
||||
|
||||
trait ErrorEmpty {
|
||||
type Output;
|
||||
fn err_empty(self) -> Result<Self::Output, ()>;
|
||||
@@ -48,12 +53,10 @@ enum WebError {
|
||||
|
||||
impl WebError {
|
||||
fn not_found() -> Self {
|
||||
let context: HashMap<String, String> = HashMap::new();
|
||||
WebError::NotFound(Template::render("404", context))
|
||||
WebError::NotFound(Template::render("404", EMPTY_MAP.deref()))
|
||||
}
|
||||
fn server_error() -> Self {
|
||||
let context: HashMap<String, String> = HashMap::new();
|
||||
WebError::ServerError(Template::render("500", context))
|
||||
WebError::ServerError(Template::render("500", EMPTY_MAP.deref()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user