cleanup of various clippy lints, bad practices and simplificaiton of some code

Signed-off-by: Jade <obsidianical@gmail.com>
This commit is contained in:
Schrottkatze 2023-02-17 22:14:43 +01:00
parent fa67edc8c5
commit 528a7b6899
11 changed files with 34 additions and 45 deletions

View file

@ -14,11 +14,11 @@ pub fn save_to_file(pasta_data: &Vec<Pasta>) {
serde_json::to_writer(writer, &pasta_data).expect("Failed to create JSON writer");
}
Err(_) => {
log::info!("Database file {} not found!", DATABASE_PATH);
log::info!("Database file {DATABASE_PATH} not found!");
file = File::create(DATABASE_PATH);
match file {
Ok(_) => {
log::info!("Database file {} created.", DATABASE_PATH);
log::info!("Database file {DATABASE_PATH} created.");
save_to_file(pasta_data);
}
Err(err) => {
@ -27,7 +27,7 @@ pub fn save_to_file(pasta_data: &Vec<Pasta>) {
&DATABASE_PATH,
&err
);
panic!("Failed to create database file {}: {}!", DATABASE_PATH, err)
panic!("Failed to create database file {DATABASE_PATH}: {err}!")
}
}
}
@ -46,10 +46,10 @@ pub fn load_from_file() -> io::Result<Vec<Pasta>> {
Ok(data)
}
Err(_) => {
log::info!("Database file {} not found!", DATABASE_PATH);
log::info!("Database file {DATABASE_PATH} not found!");
save_to_file(&Vec::<Pasta>::new());
log::info!("Database file {} created.", DATABASE_PATH);
log::info!("Database file {DATABASE_PATH} created.");
load_from_file()
}
}

View file

@ -25,7 +25,7 @@ pub fn html_highlight(text: &str, extension: &str) -> String {
let mut highlighted_content2: String = String::from("");
for line in highlighted_content.lines() {
highlighted_content2 += &*format!("<code-line>{}</code-line>\n", line);
highlighted_content2 += &*format!("<code-line>{line}</code-line>\n");
}
// Rewrite colours to ones that are compatible with water.css and both light/dark modes