From 9bb4b246e7b03cff18e36d251f47a49b77aa4e6b Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 24 Jun 2024 12:21:20 +0300 Subject: [PATCH] feat(#41): rustfmt --- .rustfmt.toml | 22 ++++++++++++++++++++++ server/src/lib.rs | 2 +- server/src/report/latex.rs | 28 ++++++++++++---------------- tests/home_test.rs | 0 4 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 .rustfmt.toml create mode 100644 tests/home_test.rs diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 00000000..917a45d4 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,22 @@ +# The MIT License (MIT) +# +# Copyright (c) 2024 Aliaksei Bialiauski +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +max_width = 90 diff --git a/server/src/lib.rs b/server/src/lib.rs index 8cbe35ca..10bcefd1 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -29,9 +29,9 @@ use tokio::net::TcpListener; use crate::routes::home; use crate::xml::storage::touch_storage; +pub mod report; mod routes; mod xml; -pub mod report; #[derive(Default)] pub struct Server { diff --git a/server/src/report/latex.rs b/server/src/report/latex.rs index 61ef1978..29b807b6 100644 --- a/server/src/report/latex.rs +++ b/server/src/report/latex.rs @@ -22,35 +22,33 @@ use std::fs; use std::path::Path; -/// /// Read LaTeX template. /// @todo #41:60min Add function for appending new content into the template. /// We need to create new function that will append input into the template, /// thus it will build a detailed report. -/// # Arguments -/// +/// # Arguments +/// /// * `path`: Template path -/// -/// returns: String -/// -/// # Examples -/// +/// +/// returns: String +/// +/// # Examples +/// /// ``` /// use crate::server::report::latex::template; /// let content = template(None); /// print!("{content}") /// ``` pub fn template(path: Option<&str>) -> String { - return fs::read_to_string( - Path::new(path.unwrap_or("resources/report.tex")) - ).unwrap(); + return fs::read_to_string(Path::new(path.unwrap_or("resources/report.tex"))) + .unwrap(); } #[cfg(test)] mod tests { + use anyhow::Result; use std::fs::File; use std::io::Write; - use anyhow::Result; use tempdir::TempDir; use crate::report::latex::template; @@ -67,8 +65,7 @@ mod tests { \end{document} "; assert_eq!( - content, - expected, + content, expected, "Template content '{content}' does not match with '{expected}'" ); Ok(()) @@ -83,8 +80,7 @@ mod tests { File::create(path).unwrap().write_all(bytes.as_slice())?; let content = template(path.to_str()); assert_eq!( - content, - expected, + content, expected, "Template content '{content} does not match with '{expected}'" ); Ok(()) diff --git a/tests/home_test.rs b/tests/home_test.rs new file mode 100644 index 00000000..e69de29b