Skip to content

Commit 3d82dec

Browse files
sonesukeclaude
andauthored
chore: update rust edition to 2024 and rust-version to 1.93 (#64)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d0ec1fc commit 3d82dec

6 files changed

Lines changed: 49 additions & 59 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "google-patent-cli"
33
version = "0.1.5"
4-
edition = "2021"
5-
rust-version = "1.81"
4+
edition = "2024"
5+
rust-version = "1.93"
66

77
[profile.release]
88
lto = "fat"

src/cli/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,12 @@ mod tests {
281281
])
282282
.expect("Cli parsing success in test");
283283

284-
std::env::set_var("HOME", temp_dir.path());
285-
std::env::set_var("XDG_CONFIG_HOME", temp_dir.path());
286-
std::env::set_var("APPDATA", temp_dir.path());
287-
std::env::set_var("USERPROFILE", temp_dir.path());
284+
unsafe {
285+
std::env::set_var("HOME", temp_dir.path());
286+
std::env::set_var("XDG_CONFIG_HOME", temp_dir.path());
287+
std::env::set_var("APPDATA", temp_dir.path());
288+
std::env::set_var("USERPROFILE", temp_dir.path());
289+
}
288290

289291
let res = run_app(cli).await;
290292
assert!(res.is_ok());

src/core/config.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ impl Config {
6767
}
6868

6969
// Priority 2: CI environment
70-
if env::var("CI").is_ok() || env::var("GITHUB_ACTIONS").is_ok() {
71-
if let Some(path) = detect_chrome_path() {
72-
// CI typically runs in containers/VMs, so add --no-sandbox
73-
return (Some(path), vec!["--no-sandbox".to_string()]);
74-
}
70+
if (env::var("CI").is_ok() || env::var("GITHUB_ACTIONS").is_ok())
71+
&& let Some(path) = detect_chrome_path()
72+
{
73+
// CI typically runs in containers/VMs, so add --no-sandbox
74+
return (Some(path), vec!["--no-sandbox".to_string()]);
7575
}
7676

7777
// Priority 3: Auto-detection
@@ -117,13 +117,12 @@ fn is_running_in_container() -> bool {
117117
}
118118

119119
// Check /proc/1/cgroup for container indicators
120-
if let Ok(content) = fs::read_to_string("/proc/1/cgroup") {
121-
if content.contains("docker")
120+
if let Ok(content) = fs::read_to_string("/proc/1/cgroup")
121+
&& (content.contains("docker")
122122
|| content.contains("kubepods")
123-
|| content.contains("containerd")
124-
{
125-
return true;
126-
}
123+
|| content.contains("containerd"))
124+
{
125+
return true;
127126
}
128127

129128
false

src/core/models.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -178,27 +178,27 @@ impl SearchOptions {
178178
let mut url_str = url.to_string();
179179

180180
// Manually append assignee parameter if present
181-
if let Some(assignees) = &self.assignee {
182-
if !assignees.is_empty() {
183-
let encoded_assignees: Vec<String> = assignees
184-
.iter()
185-
.map(|a| {
186-
// Encode each assignee value, including quotes, using form_urlencoded logic
187-
let quoted = format!("\"{}\"", a);
188-
url::form_urlencoded::byte_serialize(quoted.as_bytes()).collect::<String>()
189-
})
190-
.collect();
191-
192-
// Determine if we need to add '?' or '&'
193-
let separator = if !url_str.contains('?') {
194-
"?"
195-
} else if url_str.ends_with('?') {
196-
""
197-
} else {
198-
"&"
199-
};
200-
url_str.push_str(&format!("{}assignee={}", separator, encoded_assignees.join(",")));
201-
}
181+
if let Some(assignees) = &self.assignee
182+
&& !assignees.is_empty()
183+
{
184+
let encoded_assignees: Vec<String> = assignees
185+
.iter()
186+
.map(|a| {
187+
// Encode each assignee value, including quotes, using form_urlencoded logic
188+
let quoted = format!("\"{}\"", a);
189+
url::form_urlencoded::byte_serialize(quoted.as_bytes()).collect::<String>()
190+
})
191+
.collect();
192+
193+
// Determine if we need to add '?' or '&'
194+
let separator = if !url_str.contains('?') {
195+
"?"
196+
} else if url_str.ends_with('?') {
197+
""
198+
} else {
199+
"&"
200+
};
201+
url_str.push_str(&format!("{}assignee={}", separator, encoded_assignees.join(",")));
202202
}
203203

204204
// Manual check for empty params (after constructing)

src/core/patent_search.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,7 @@ fn parse_single_patent_result(
225225
})
226226
})
227227
.collect();
228-
if parsed.is_empty() {
229-
None
230-
} else {
231-
Some(parsed)
232-
}
228+
if parsed.is_empty() { None } else { Some(parsed) }
233229
});
234230

235231
// Parse claims
@@ -244,11 +240,7 @@ fn parse_single_patent_result(
244240
})
245241
})
246242
.collect();
247-
if parsed.is_empty() {
248-
None
249-
} else {
250-
Some(parsed)
251-
}
243+
if parsed.is_empty() { None } else { Some(parsed) }
252244
});
253245

254246
// Parse images
@@ -262,11 +254,7 @@ fn parse_single_patent_result(
262254
})
263255
})
264256
.collect();
265-
if parsed.is_empty() {
266-
None
267-
} else {
268-
Some(parsed)
269-
}
257+
if parsed.is_empty() { None } else { Some(parsed) }
270258
});
271259

272260
let filing_date = result["filing_date"].as_str().map(String::from);
@@ -302,10 +290,10 @@ fn parse_single_patent_result(
302290
fn parse_search_results(results: serde_json::Value, limit: Option<usize>) -> Result<SearchResult> {
303291
let mut sr: SearchResult = serde_json::from_value(results)?;
304292

305-
if let Some(limit) = limit {
306-
if sr.patents.len() > limit {
307-
sr.patents.truncate(limit);
308-
}
293+
if let Some(limit) = limit
294+
&& sr.patents.len() > limit
295+
{
296+
sr.patents.truncate(limit);
309297
}
310298

311299
Ok(sr)

src/mcp/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ use crate::core::models::SearchOptions;
33
use crate::core::models::{Patent, SearchResult};
44
use crate::core::patent_search::{PatentSearch, PatentSearcher};
55
use rmcp::{
6+
ErrorData, RoleServer, ServerHandler, ServiceExt,
67
handler::server::{tool::ToolRouter, wrapper::Parameters},
78
model::{
89
ErrorCode, Implementation, ProtocolVersion, ServerCapabilities, ServerInfo, ToolsCapability,
910
},
10-
schemars::{self, schema_for, JsonSchema},
11+
schemars::{self, JsonSchema, schema_for},
1112
service::{NotificationContext, RequestContext},
12-
tool, tool_handler, tool_router, ErrorData, RoleServer, ServerHandler, ServiceExt,
13+
tool, tool_handler, tool_router,
1314
};
1415
use serde::{Deserialize, Serialize};
1516
use serde_json::Value;

0 commit comments

Comments
 (0)