diff options
| author | Fuwn <[email protected]> | 2024-07-17 00:10:11 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-07-17 00:10:11 -0700 |
| commit | 938e3e9e2c9864d8a6aacd01ac95ca8768c509d4 (patch) | |
| tree | b2a9bace127118a7c2d018920fe0fd90c51f3e5c /src | |
| parent | deps(windmark): bump (diff) | |
| download | locus-938e3e9e2c9864d8a6aacd01ac95ca8768c509d4.tar.xz locus-938e3e9e2c9864d8a6aacd01ac95ca8768c509d4.zip | |
refactor: clippy lints
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/finger.rs | 19 | ||||
| -rw-r--r-- | src/modules/web.rs | 23 | ||||
| -rw-r--r-- | src/route.rs | 4 |
3 files changed, 22 insertions, 24 deletions
diff --git a/src/modules/finger.rs b/src/modules/finger.rs index 7992703..59c07a0 100644 --- a/src/modules/finger.rs +++ b/src/modules/finger.rs @@ -7,15 +7,13 @@ use { pub fn module(router: &mut windmark::router::Router) { track_mount(router, "/finger", "Finger-to-Gemini Gateway", |context| { success( - &format!( - r"# Finger-to-Gemini Gateway + &r"# Finger-to-Gemini Gateway To use this gateway, simply append the address of your target resource to the end of the current route, minus the protocol. Routed paths are supported! To visit my personal Finger server, <finger://fuwn.me>, you would visit <gemini://fuwn.me/finger/fuwn.me>. -=> /finger/fuwn.me Try it!" - ), +=> /finger/fuwn.me Try it!".to_string(), &context, ) }); @@ -27,15 +25,15 @@ To visit my personal Finger server, <finger://fuwn.me>, you would visit <gemini: if let Some(uri) = context.parameters.get("uri") { let path; let url = url::Url::parse({ - let mut parts = uri.split("/"); + let mut parts = uri.split('/'); let host = parts.next().unwrap(); path = parts.collect::<Vec<&str>>().join("/"); - &if !host.contains(":") { - format!("{}:79", host) - } else { + &if host.contains(':') { host.to_string() + } else { + format!("{host}:79") } }) .unwrap(); @@ -48,8 +46,7 @@ To visit my personal Finger server, <finger://fuwn.me>, you would visit <gemini: let mut response = String::new(); - response.push_str(format!("=> finger://{}\n\n", uri).as_str()); - + response.push_str(format!("=> finger://{uri}\n\n").as_str()); response.push_str("```\n"); loop { @@ -57,7 +54,7 @@ To visit my personal Finger server, <finger://fuwn.me>, you would visit <gemini: Ok(0) => break, Ok(n) => n, Err(e) => { - eprintln!("error: failed to read from socket: {:?}", e); + eprintln!("error: failed to read from socket: {e:?}"); break; } diff --git a/src/modules/web.rs b/src/modules/web.rs index 037a08d..76e09ff 100644 --- a/src/modules/web.rs +++ b/src/modules/web.rs @@ -76,11 +76,11 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v if let Some(id) = queries.get("id") { nodes = if let Some(element) = dom.get_element_by_id(id.as_str()) { - if let Some(children) = element.get(parser).unwrap().children() { - children.all(parser).iter().peekable() - } else { - nodes - } + element + .get(parser) + .unwrap() + .children() + .map_or(nodes, |children| children.all(parser).iter().peekable()) } else { nodes }; @@ -88,13 +88,13 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v if let Some(id) = queries.get("class") { nodes = if let Some(element) = - dom.get_elements_by_class_name(id.as_str()).nth(0) + dom.get_elements_by_class_name(id.as_str()).next() { - if let Some(children) = element.get(parser).unwrap().children() { - children.all(parser).iter().peekable() - } else { - nodes - } + element + .get(parser) + .unwrap() + .children() + .map_or(nodes, |children| children.all(parser).iter().peekable()) } else { nodes }; @@ -177,6 +177,7 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v ), )); } + #[allow(clippy::match_same_arms)] "html" | "head" | "script" | "link" | "title" | "body" | "ul" | "style" => {} _ => { diff --git a/src/route.rs b/src/route.rs index f484a56..12cc8f1 100644 --- a/src/route.rs +++ b/src/route.rs @@ -39,9 +39,9 @@ pub fn track_mount<F, R>( R: IntoFuture<Output = windmark::response::Response> + Send + 'static, <R as IntoFuture>::IntoFuture: Send, { - if !description.starts_with("-") { + if !description.starts_with('-') { (*ROUTES.lock().unwrap()) - .insert(route.to_string(), Route::new(&description.replacen("-", "", 1))); + .insert(route.to_string(), Route::new(&description.replacen('-', "", 1))); } router.mount(route, handler); |