aboutsummaryrefslogtreecommitdiff
path: root/src/command/generate.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-04-06 00:57:56 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-04-06 00:57:56 +0200
commitd0f582b98712d967b2f95d0405886d063bd89468 (patch)
treecc644c21278d336772557366bcdd3e46b22065db /src/command/generate.rs
parent8b3b94a38b443c50afc5b42cca45db7c18ce280d (diff)
Get stricter clippy
Diffstat (limited to 'src/command/generate.rs')
-rw-r--r--src/command/generate.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/command/generate.rs b/src/command/generate.rs
index ac9849e..33ea6a4 100644
--- a/src/command/generate.rs
+++ b/src/command/generate.rs
@@ -21,9 +21,8 @@ impl Generate {
for i in 0..max_posts {
let post_path = posts_directory.join(i.to_string());
- match Generate::read_post(&post_path, i) {
- Some(post) => posts.push(post),
- None => continue,
+ if let Some(post) = Generate::read_post(&post_path, i) {
+ posts.push(post);
}
}
@@ -34,16 +33,13 @@ impl Generate {
let entries = read_dir(post_path).ok()?;
for entry in entries.filter_map(Result::ok) {
let entry_path = entry.path();
- match entry_path.extension() {
- Some(extension) => {
- if extension == "gmi" {
- let mut file = File::open(entry_path).ok()?;
- let mut contents = String::new();
- file.read_to_string(&mut contents).ok()?;
- return Some(contents);
- }
+ if let Some(extension) = entry_path.extension() {
+ if extension == "gmi" {
+ let mut file = File::open(entry_path).ok()?;
+ let mut contents = String::new();
+ file.read_to_string(&mut contents).ok()?;
+ return Some(contents);
}
- None => continue,
}
}
None
@@ -190,7 +186,7 @@ mod tests {
.write_all(&invalid_bytes)
.expect("Could not write bad bytes to bad file.");
- let mut configuration = Configuration::new();
+ let mut configuration = Configuration::new().unwrap();
configuration.archive_directory = archive_dir.clone();
configuration.static_directory = static_dir.clone();
configuration.templates_directory = template_dir.clone();
@@ -263,7 +259,7 @@ mod tests {
"{ \"id\": \"1736045200000\", \"created_on\": 1736045200000 }",
);
- let mut configuration = Configuration::new();
+ let mut configuration = Configuration::new().unwrap();
configuration.archive_directory = archive_dir.clone();
configuration.static_directory = static_dir.clone();
configuration.templates_directory = template_dir.clone();