Parcourir la source

Remove unused imports and simplify namespaces.

Alexandre Leblanc il y a 3 ans
Parent
commit
09bd614fa7
3 fichiers modifiés avec 10 ajouts et 20 suppressions
  1. 0 3
      src/articles_repository.rs
  2. 9 14
      src/main.rs
  3. 1 3
      src/theme.rs

+ 0 - 3
src/articles_repository.rs

@@ -1,6 +1,3 @@
-use std::io::Error;
-use std::{fs, io};
-
 use walkdir::WalkDir;
 
 pub trait ArticlesRepository {

+ 9 - 14
src/main.rs

@@ -6,14 +6,12 @@ mod vcs;
 extern crate chrono;
 
 use actix_web::middleware::Logger;
-use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
+use actix_web::{get, web, App, HttpResponse, HttpServer, Responder};
 use fern;
-use log::error;
-use std::{env, fs, io};
+use std::{env, io};
 
 use articles_repository::{ArticlesRepository, FsRepository};
 use config::Configuration;
-use pulldown_cmark::{html, Options, Parser};
 use theme::Theme;
 
 #[get("")]
@@ -22,7 +20,7 @@ async fn show_articles_list() -> impl Responder {
 
     const CONTENT_FOLDER: &str = "./content";
     let exe_dir = env::current_dir()
-        .and_then(|dir| io::Result::Ok(dir.to_str().unwrap_or("").to_string()))
+        .and_then(|dir| Ok(dir.to_str().unwrap_or("").to_string()))
         .unwrap();
     log::trace!("Estimated content repository: {exe_dir}/{CONTENT_FOLDER}");
 
@@ -36,7 +34,7 @@ async fn show_article(path: web::Path<(String,)>) -> impl Responder {
     let p = format!("./content/{}", &path.0);
 
     let exe_dir = env::current_dir()
-        .and_then(|dir| io::Result::Ok(dir.to_str().unwrap_or("").to_string()))
+        .and_then(|dir| Ok(dir.to_str().unwrap_or("").to_string()))
         .unwrap();
 
     let theme_path = format!("{}/www/themes/default", exe_dir);
@@ -56,9 +54,9 @@ async fn show_article(path: web::Path<(String,)>) -> impl Responder {
 }
 
 #[actix_web::main]
-async fn main() -> std::io::Result<()> {
-    if !std::env::vars().any(|(k, _)| k == "RUST_LOG") {
-        std::env::set_var("RUST_LOG", "trace");
+async fn main() -> io::Result<()> {
+    if !env::vars().any(|(k, _)| k == "RUST_LOG") {
+        env::set_var("RUST_LOG", "trace");
     }
 
     let config = Configuration::default();
@@ -74,7 +72,7 @@ async fn main() -> std::io::Result<()> {
             ))
         })
         .level(log::LevelFilter::Info)
-        .chain(std::io::stdout())
+        .chain(io::stdout())
         .apply();
 
     HttpServer::new(|| {
@@ -85,10 +83,7 @@ async fn main() -> std::io::Result<()> {
                 "/images",
                 "./www/themes/default/images",
             ))
-            .service(actix_files::Files::new(
-                "/js",
-                "./www/themes/default/js",
-            ))
+            .service(actix_files::Files::new("/js", "./www/themes/default/js"))
             .service(
                 web::scope("/a")
                     .service(show_article)

+ 1 - 3
src/theme.rs

@@ -1,6 +1,4 @@
 use pulldown_cmark::{html, Parser};
-use std::error::Error;
-use std::path::Path;
 
 pub struct Theme {
     root_path: String,
@@ -53,4 +51,4 @@ impl Theme {
         log::trace!("Loading fragment file '{}'", path);
         std::fs::read_to_string(path).unwrap_or("".to_owned())
     }
-}
+}