Skip to content

Commit

Permalink
feat(#41): rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Jun 24, 2024
1 parent 8bcbdcd commit 9bb4b24
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
22 changes: 22 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 12 additions & 16 deletions server/src/report/latex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -67,8 +65,7 @@ mod tests {
\end{document}
";
assert_eq!(
content,
expected,
content, expected,
"Template content '{content}' does not match with '{expected}'"
);
Ok(())
Expand All @@ -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(())
Expand Down
Empty file added tests/home_test.rs
Empty file.

0 comments on commit 9bb4b24

Please sign in to comment.