fix: apply rustfmt and replace map_or with is_some_and per clippy

This commit is contained in:
NetworkCats
2026-03-22 18:23:22 +08:00
parent 991fd289a2
commit c15d7ad36a
4 changed files with 6 additions and 9 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ use maxminddb::Reader;
use serde::Deserialize;
use crate::models::{
from_mmdb_record, IpInfo, MmdbAsn, MmdbCity, MmdbCountry, MmdbProxy, MmdbRecord, ProxyInfo,
IpInfo, MmdbAsn, MmdbCity, MmdbCountry, MmdbProxy, MmdbRecord, ProxyInfo, from_mmdb_record,
};
pub type DbReader = Reader<Vec<u8>>;
+1 -1
View File
@@ -81,7 +81,7 @@ fn proxy_field_handler(
return Err(AppError::DbNotReady);
}
let ip = resolve_ip(headers, query, state.dev_mode)?;
let value = db::lookup_proxy(&state.db, ip).map_or(false, |p| field(&p));
let value = db::lookup_proxy(&state.db, ip).is_some_and(|p| field(&p));
Ok(format!("{value}\n"))
}
+2 -5
View File
@@ -23,9 +23,7 @@ pub use api::{
vpn_handler,
};
pub use html::{not_found, root, root_redirect, root_trailing_slash};
pub use seo::{
build_openapi_json, favicon, manifest, openapi_json, robots_txt, sitemap_xml,
};
pub use seo::{build_openapi_json, favicon, manifest, openapi_json, robots_txt, sitemap_xml};
#[derive(serde::Deserialize)]
pub struct IpQuery {
@@ -107,8 +105,7 @@ fn handle_non_browser_request(
if wants_json(headers) && query.ip.is_none() {
return Some(
match extract_client_ip(headers, state.dev_mode)
.and_then(|ip| lookup_ip(&state.db, ip))
match extract_client_ip(headers, state.dev_mode).and_then(|ip| lookup_ip(&state.db, ip))
{
Ok(info) => axum::Json(info).into_response(),
Err(e) => e.into_response(),
+2 -2
View File
@@ -17,8 +17,8 @@ pub async fn openapi_json(State(state): State<AppState>) -> Response {
}
pub fn build_openapi_json(site_domain: &str) -> Arc<str> {
let mut spec: serde_json::Value =
serde_json::from_str(include_str!("../../openapi.json")).expect("openapi.json must be valid");
let mut spec: serde_json::Value = serde_json::from_str(include_str!("../../openapi.json"))
.expect("openapi.json must be valid");
let server_url = format!("https://{site_domain}");
spec["servers"] = serde_json::json!([{ "url": server_url }]);