mirror of
https://github.com/0xMassi/webclaw.git
synced 2026-06-15 23:35:14 +02:00
style(mcp): apply rustfmt to numeric param coercion
Reformat the string-or-number deserialize helpers and tests to satisfy `cargo fmt --check` (style_edition 2024), which the lint CI job enforces. Formatting only — no behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b5ee838d5f
commit
24ae3a7af2
1 changed files with 15 additions and 22 deletions
|
|
@ -28,11 +28,11 @@ where
|
|||
match Option::<NumOrStr>::deserialize(d)? {
|
||||
None => Ok(None),
|
||||
Some(NumOrStr::Num(n)) => Ok(Some(n)),
|
||||
Some(NumOrStr::Str(s)) => s
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
.map(Some)
|
||||
.map_err(|_| serde::de::Error::custom(format!("expected a u32, got string \"{s}\""))),
|
||||
Some(NumOrStr::Str(s)) => {
|
||||
s.trim().parse::<u32>().map(Some).map_err(|_| {
|
||||
serde::de::Error::custom(format!("expected a u32, got string \"{s}\""))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,13 +49,11 @@ where
|
|||
match Option::<NumOrStr>::deserialize(d)? {
|
||||
None => Ok(None),
|
||||
Some(NumOrStr::Num(n)) => Ok(Some(n)),
|
||||
Some(NumOrStr::Str(s)) => s
|
||||
.trim()
|
||||
.parse::<usize>()
|
||||
.map(Some)
|
||||
.map_err(|_| {
|
||||
Some(NumOrStr::Str(s)) => {
|
||||
s.trim().parse::<usize>().map(Some).map_err(|_| {
|
||||
serde::de::Error::custom(format!("expected a usize, got string \"{s}\""))
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,8 +197,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn crawl_depth_from_number() {
|
||||
let v: CrawlParams =
|
||||
serde_json::from_str(r#"{"url":"https://x.com","depth":3}"#).unwrap();
|
||||
let v: CrawlParams = serde_json::from_str(r#"{"url":"https://x.com","depth":3}"#).unwrap();
|
||||
assert_eq!(v.depth, Some(3));
|
||||
}
|
||||
|
||||
|
|
@ -240,8 +237,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn crawl_max_pages_non_numeric_string_errors() {
|
||||
let e =
|
||||
serde_json::from_str::<CrawlParams>(r#"{"url":"https://x.com","max_pages":"abc"}"#);
|
||||
let e = serde_json::from_str::<CrawlParams>(r#"{"url":"https://x.com","max_pages":"abc"}"#);
|
||||
assert!(e.is_err(), "expected Err, got {e:?}");
|
||||
}
|
||||
|
||||
|
|
@ -269,9 +265,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn crawl_concurrency_non_numeric_string_errors() {
|
||||
let e = serde_json::from_str::<CrawlParams>(
|
||||
r#"{"url":"https://x.com","concurrency":"abc"}"#,
|
||||
);
|
||||
let e =
|
||||
serde_json::from_str::<CrawlParams>(r#"{"url":"https://x.com","concurrency":"abc"}"#);
|
||||
assert!(e.is_err(), "expected Err, got {e:?}");
|
||||
}
|
||||
|
||||
|
|
@ -316,8 +311,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn search_num_results_from_number() {
|
||||
let v: SearchParams =
|
||||
serde_json::from_str(r#"{"query":"rust","num_results":10}"#).unwrap();
|
||||
let v: SearchParams = serde_json::from_str(r#"{"query":"rust","num_results":10}"#).unwrap();
|
||||
assert_eq!(v.num_results, Some(10));
|
||||
}
|
||||
|
||||
|
|
@ -329,8 +323,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn search_num_results_non_numeric_string_errors() {
|
||||
let e =
|
||||
serde_json::from_str::<SearchParams>(r#"{"query":"rust","num_results":"abc"}"#);
|
||||
let e = serde_json::from_str::<SearchParams>(r#"{"query":"rust","num_results":"abc"}"#);
|
||||
assert!(e.is_err(), "expected Err, got {e:?}");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue