From 972e2e613f5a65039cf87b5d54092ac21a0828d2 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 21 Jan 2026 01:21:41 -0800 Subject: refactor: Bump nightlky Rust toolchain channel and fix lints --- src/modules/blog/config.rs | 26 +++++++++++++++++--------- src/modules/blog/module.rs | 34 +++++++++++++++++----------------- src/modules/finger.rs | 8 ++++---- src/modules/index.rs | 4 ++-- 4 files changed, 40 insertions(+), 32 deletions(-) (limited to 'src/modules') diff --git a/src/modules/blog/config.rs b/src/modules/blog/config.rs index c2e4cc9..c4c7ced 100644 --- a/src/modules/blog/config.rs +++ b/src/modules/blog/config.rs @@ -12,15 +12,19 @@ pub struct Entry { name: Option, } impl Entry { - pub const fn description(&self) -> &Option { &self.description } + pub const fn description(&self) -> Option<&String> { + self.description.as_ref() + } - pub const fn author(&self) -> &Option { &self.author } + pub const fn author(&self) -> Option<&String> { self.author.as_ref() } - pub const fn name(&self) -> &Option { &self.name } + pub const fn name(&self) -> Option<&String> { self.name.as_ref() } - pub const fn created(&self) -> &Option { &self.created } + pub const fn created(&self) -> Option<&String> { self.created.as_ref() } - pub const fn last_modified(&self) -> &Option { &self.last_modified } + pub const fn last_modified(&self) -> Option<&String> { + self.last_modified.as_ref() + } } #[derive(Serialize, Deserialize, Clone, Default)] @@ -31,13 +35,17 @@ pub struct Blog { priority: Option, } impl Blog { - pub const fn description(&self) -> &Option { &self.description } + pub const fn description(&self) -> Option<&String> { + self.description.as_ref() + } - pub const fn name(&self) -> &Option { &self.name } + pub const fn name(&self) -> Option<&String> { self.name.as_ref() } - pub const fn posts(&self) -> &Option> { &self.posts } + pub const fn posts(&self) -> Option<&HashMap> { + self.posts.as_ref() + } - pub const fn priority(&self) -> &Option { &self.priority } + pub const fn priority(&self) -> Option<&u8> { self.priority.as_ref() } pub fn from_string(string: &str) -> serde_json::Result { serde_json::from_str(string) diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs index 8ffff90..2fda040 100644 --- a/src/modules/blog/module.rs +++ b/src/modules/blog/module.rs @@ -39,7 +39,7 @@ pub fn module(router: &mut windmark::router::Router) { if std::path::Path::new(&entry_key) .extension() - .map_or(false, |extension| extension.eq_ignore_ascii_case("gmi")) + .is_some_and(|extension| extension.eq_ignore_ascii_case("gmi")) { entry_key.truncate(entry_key.len() - 4); } @@ -99,11 +99,12 @@ pub fn module(router: &mut windmark::router::Router) { .map(|(blog, entries)| { ( blog, - *entries + entries .get("blog.json") .and_then(|content| Blog::from_string(content).ok()) .unwrap_or_default() - .priority(), + .priority() + .copied(), entries, ) }) @@ -125,11 +126,11 @@ pub fn module(router: &mut windmark::router::Router) { .and_then(|content| Blog::from_string(content).ok()); let name = config .as_ref() - .and_then(|c| c.name().as_ref()) + .and_then(|c| c.name()) .cloned() .unwrap_or_else(|| title.clone()); let description = - config.as_ref().and_then(|c| c.description().as_ref()).cloned(); + config.as_ref().and_then(|c| c.description()).cloned(); format!( "=> {} {}{}", @@ -158,11 +159,10 @@ pub fn module(router: &mut windmark::router::Router) { let entries_clone = entries.clone(); let name = config .as_ref() - .and_then(|c| c.name().as_ref()) + .and_then(|c| c.name()) .cloned() .unwrap_or_else(|| blog.clone()); - let description = - config.as_ref().and_then(|c| c.description().as_ref()).cloned(); + let description = config.as_ref().and_then(|c| c.description()).cloned(); let config_clone = config.clone(); let mut xml = XmlWriter::builder(); @@ -197,13 +197,13 @@ pub fn module(router: &mut windmark::router::Router) { {0}'s RSS feed\n\n=> {} here!", blog, entries_clone.len(), - description.as_deref().unwrap_or(""), + description.as_deref().map_or("", |v| v), entries_clone .keys() .map(|title| { let postish = config_clone .as_ref() - .and_then(|c| c.posts().as_ref()) + .and_then(|c| c.posts()) .and_then(|posts| posts.get(title)) .cloned() .unwrap_or_default(); @@ -215,10 +215,10 @@ pub fn module(router: &mut windmark::router::Router) { fixed_blog_name, title.to_lowercase() ), - { postish.name().clone().unwrap_or_else(|| title.clone()) }, + { postish.name().cloned().unwrap_or_else(|| title.clone()) }, { let post = - postish.description().clone().unwrap_or_default(); + postish.description().cloned().unwrap_or_default(); if post.is_empty() { String::new() @@ -238,7 +238,7 @@ pub fn module(router: &mut windmark::router::Router) { ); for (title, contents) in entries { - let header = construct_header(&config, &title) + let header = construct_header(config.as_ref(), &title) .unwrap_or_else(|()| (String::new(), String::new())); let fixed_blog_name = fixed_blog_name_clone_2.clone(); let mut real_title = "Unknown"; @@ -326,11 +326,11 @@ pub fn module(router: &mut windmark::router::Router) { } fn construct_header( - config: &Option, + config: Option<&Blog>, name: &str, ) -> Result<(String, String), ()> { let post = - if let Some(posts) = config.clone().unwrap_or_default().posts().clone() { + if let Some(posts) = config.cloned().unwrap_or_default().posts().cloned() { if let Some(post) = posts.get(name) { post.clone() } else { @@ -359,7 +359,7 @@ fn construct_header( Ok(( format!( "# {}\n{}{}{}{}{}", - post.name().clone().unwrap_or_else(|| name.to_string()), + post.name().cloned().unwrap_or_else(|| name.to_string()), if any_is_some![author, created, last_modified, description] { "\n" } else { @@ -370,6 +370,6 @@ fn construct_header( field!(last_modified, " (last modified on {})\n"), field!(description, "\n{}\n"), ), - post.description().clone().unwrap_or_default(), + post.description().cloned().unwrap_or_default(), )) } diff --git a/src/modules/finger.rs b/src/modules/finger.rs index 59c07a0..4e41d16 100644 --- a/src/modules/finger.rs +++ b/src/modules/finger.rs @@ -24,19 +24,19 @@ To visit my personal Finger server, , you would visit >().join("/"); - &if host.contains(':') { + if host.contains(':') { host.to_string() } else { format!("{host}:79") } - }) - .unwrap(); + }; + let url = url::Url::parse(&original_url).unwrap(); let mut stream = tokio::net::TcpStream::connect(url.to_string()).await.unwrap(); diff --git a/src/modules/index.rs b/src/modules/index.rs index 0f7749a..1dfa66f 100644 --- a/src/modules/index.rs +++ b/src/modules/index.rs @@ -8,7 +8,7 @@ pub fn module(router: &mut windmark::router::Router) { move |context| { crate::response::success( &format!( - r#"# Fuwn[.me] + r"# Fuwn[.me] I enjoy writing for archaic systems in dated languages and with artificially imposed constraints, all while aiming for peak performance and minimal design. @@ -30,7 +30,7 @@ I write a lot of software and tooling for the Gemini protocol, the backbone of t Don't know where to start? Check out The Directory or test your luck! => /directory The Directory -=> /random I'm Feeling Lucky"#, +=> /random I'm Feeling Lucky", { (*POSTS).lock().map_or_else( |_| "...".to_string(), -- cgit v1.2.3