Skip to content

Commit c15d7ad

Browse files
committed
fix: apply rustfmt and replace map_or with is_some_and per clippy
1 parent 991fd28 commit c15d7ad

4 files changed

Lines changed: 6 additions & 9 deletions

File tree

src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use maxminddb::Reader;
99
use serde::Deserialize;
1010

1111
use crate::models::{
12-
from_mmdb_record, IpInfo, MmdbAsn, MmdbCity, MmdbCountry, MmdbProxy, MmdbRecord, ProxyInfo,
12+
IpInfo, MmdbAsn, MmdbCity, MmdbCountry, MmdbProxy, MmdbRecord, ProxyInfo, from_mmdb_record,
1313
};
1414

1515
pub type DbReader = Reader<Vec<u8>>;

src/handlers/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn proxy_field_handler(
8181
return Err(AppError::DbNotReady);
8282
}
8383
let ip = resolve_ip(headers, query, state.dev_mode)?;
84-
let value = db::lookup_proxy(&state.db, ip).map_or(false, |p| field(&p));
84+
let value = db::lookup_proxy(&state.db, ip).is_some_and(|p| field(&p));
8585
Ok(format!("{value}\n"))
8686
}
8787

src/handlers/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ pub use api::{
2323
vpn_handler,
2424
};
2525
pub use html::{not_found, root, root_redirect, root_trailing_slash};
26-
pub use seo::{
27-
build_openapi_json, favicon, manifest, openapi_json, robots_txt, sitemap_xml,
28-
};
26+
pub use seo::{build_openapi_json, favicon, manifest, openapi_json, robots_txt, sitemap_xml};
2927

3028
#[derive(serde::Deserialize)]
3129
pub struct IpQuery {
@@ -107,8 +105,7 @@ fn handle_non_browser_request(
107105

108106
if wants_json(headers) && query.ip.is_none() {
109107
return Some(
110-
match extract_client_ip(headers, state.dev_mode)
111-
.and_then(|ip| lookup_ip(&state.db, ip))
108+
match extract_client_ip(headers, state.dev_mode).and_then(|ip| lookup_ip(&state.db, ip))
112109
{
113110
Ok(info) => axum::Json(info).into_response(),
114111
Err(e) => e.into_response(),

src/handlers/seo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub async fn openapi_json(State(state): State<AppState>) -> Response {
1717
}
1818

1919
pub fn build_openapi_json(site_domain: &str) -> Arc<str> {
20-
let mut spec: serde_json::Value =
21-
serde_json::from_str(include_str!("../../openapi.json")).expect("openapi.json must be valid");
20+
let mut spec: serde_json::Value = serde_json::from_str(include_str!("../../openapi.json"))
21+
.expect("openapi.json must be valid");
2222

2323
let server_url = format!("https://{site_domain}");
2424
spec["servers"] = serde_json::json!([{ "url": server_url }]);

0 commit comments

Comments
 (0)