Skip to content

Commit 9b2632f

Browse files
chore(dep): bump the deps group with 9 updates (#157)
* chore(dep): bump the deps group with 9 updates Bumps the deps group with 9 updates: | Package | From | To | | --- | --- | --- | | [clap](https://github.com/clap-rs/clap) | `4.5.4` | `4.5.8` | | [log](https://github.com/rust-lang/log) | `0.4.21` | `0.4.22` | | [pyo3](https://github.com/pyo3/pyo3) | `0.21.2` | `0.22.0` | | [serde_json](https://github.com/serde-rs/json) | `1.0.117` | `1.0.120` | | [toml](https://github.com/toml-rs/toml) | `0.8.13` | `0.8.14` | | [regex](https://github.com/rust-lang/regex) | `1.10.4` | `1.10.5` | | [clap_complete](https://github.com/clap-rs/clap) | `4.5.2` | `4.5.7` | | [diesel](https://github.com/diesel-rs/diesel) | `2.2.0` | `2.2.1` | | [reqwest](https://github.com/seanmonstar/reqwest) | `0.12.4` | `0.12.5` | Updates `clap` from 4.5.4 to 4.5.8 - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](clap-rs/clap@clap_complete-v4.5.4...v4.5.8) Updates `log` from 0.4.21 to 0.4.22 - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](rust-lang/log@0.4.21...0.4.22) Updates `pyo3` from 0.21.2 to 0.22.0 - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](PyO3/pyo3@v0.21.2...v0.22.0) Updates `serde_json` from 1.0.117 to 1.0.120 - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](serde-rs/json@v1.0.117...v1.0.120) Updates `toml` from 0.8.13 to 0.8.14 - [Commits](toml-rs/toml@toml-v0.8.13...toml-v0.8.14) Updates `regex` from 1.10.4 to 1.10.5 - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](rust-lang/regex@1.10.4...1.10.5) Updates `clap_complete` from 4.5.2 to 4.5.7 - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](clap-rs/clap@clap_complete-v4.5.2...clap_complete-v4.5.7) Updates `diesel` from 2.2.0 to 2.2.1 - [Release notes](https://github.com/diesel-rs/diesel/releases) - [Changelog](https://github.com/diesel-rs/diesel/blob/v2.2.1/CHANGELOG.md) - [Commits](diesel-rs/diesel@v2.2.0...v2.2.1) Updates `reqwest` from 0.12.4 to 0.12.5 - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](seanmonstar/reqwest@v0.12.4...v0.12.5) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: deps - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps - dependency-name: clap_complete dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps - dependency-name: diesel dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps - dependency-name: reqwest dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps ... Signed-off-by: dependabot[bot] <[email protected]> * chore(clippy): make clippy happy * chore(clippy): make clippy happy * chore(ver): bumps version to 0.4.4 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: clearloop <[email protected]> Co-authored-by: clearloop <[email protected]>
1 parent 13d5416 commit 9b2632f

File tree

13 files changed

+213
-135
lines changed

13 files changed

+213
-135
lines changed

Cargo.lock

+151-71
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ path = "src/bin/lc.rs"
44

55
[package]
66
name = "leetcode-cli"
7-
version = "0.4.3"
7+
version = "0.4.4"
88
authors = ["clearloop <[email protected]>"]
99
edition = "2021"
1010
description = "Leetcode command-line interface in rust."
@@ -18,30 +18,30 @@ readme = './README.md'
1818
[dependencies]
1919
async-trait = "0.1.80"
2020
tokio = { version = "1.38.0", features = ["full"] }
21-
clap = { version = "4.5.4", features = ["cargo"] }
21+
clap = { version = "4.5.8", features = ["cargo"] }
2222
colored = "2.1.0"
2323
dirs = "5.0.1"
2424
env_logger = "0.11.3"
2525
keyring = "2.3.3"
26-
log = "0.4.21"
26+
log = "0.4.22"
2727
openssl = "0.10.64"
28-
pyo3 = { version = "0.21.2", optional = true }
28+
pyo3 = { version = "0.22.0", optional = true }
2929
rand = "0.8.5"
3030
serde = { version = "1.0.203", features = ["derive"] }
31-
serde_json = "1.0.117"
32-
toml = "0.8.13"
33-
regex = "1.10.4"
31+
serde_json = "1.0.120"
32+
toml = "0.8.14"
33+
regex = "1.10.5"
3434
scraper = "0.19.0"
3535
anyhow = "1.0.86"
36-
clap_complete = "4.5.2"
36+
clap_complete = "4.5.7"
3737
thiserror = "1.0.61"
3838

3939
[dependencies.diesel]
40-
version = "2.2.0"
40+
version = "2.2.1"
4141
features = ["sqlite"]
4242

4343
[dependencies.reqwest]
44-
version = "0.12.4"
44+
version = "0.12.5"
4545
features = ["gzip", "json"]
4646

4747
[features]

src/cache/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@ pub fn conn(p: String) -> SqliteConnection {
2323

2424
/// Condition submit or test
2525
#[derive(Clone, Debug)]
26+
#[derive(Default)]
2627
pub enum Run {
2728
Test,
29+
#[default]
2830
Submit,
2931
}
3032

31-
impl Default for Run {
32-
fn default() -> Self {
33-
Run::Submit
34-
}
35-
}
3633

3734
/// Requests if data not download
3835
#[derive(Clone)]

src/cache/parser.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ pub fn problem(problems: &mut Vec<Problem>, v: Value) -> Option<()> {
1515
// Handle on leetcode-com
1616
Some(s) => s as i32,
1717
// Handle on leetcode-cn
18-
None => fid_obj.as_str()?.split(" ").last()?.parse::<i32>().ok()?,
18+
None => fid_obj.as_str()?.split(' ').last()?.parse::<i32>().ok()?,
1919
};
2020

2121
problems.push(Problem {
2222
category: v.get("category_slug")?.as_str()?.to_string(),
23-
fid: fid,
23+
fid,
2424
id: stat.get("question_id")?.as_i64()? as i32,
2525
level: p.get("difficulty")?.as_object()?.get("level")?.as_i64()? as i32,
2626
locked: p.get("paid_only")?.as_bool()?,
@@ -102,7 +102,7 @@ pub fn daily(v: Value) -> Option<i32> {
102102
// Handle on leetcode-com
103103
Some(v) => v,
104104
// Handle on leetcode-cn
105-
None => v_obj.get("todayRecord")?.as_array()?.get(0)?,
105+
None => v_obj.get("todayRecord")?.as_array()?.first()?,
106106
}
107107
.as_object()?
108108
.get("question")?

src/cmds/list.rs

-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ impl Command for ListCommand {
184184
.get_many::<i32>("range")
185185
.ok_or(Error::NoneError)?
186186
.copied()
187-
.into_iter()
188187
.collect();
189188
ps.retain(|x| num_range[0] <= x.fid && x.fid <= num_range[1]);
190189
}

src/cmds/pick.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,8 @@ impl Command for PickCommand {
139139
let fid = match m.contains_id("name") {
140140
// check for name specified, or closest name
141141
true => {
142-
match m.get_one::<String>("name").map(|name| name) {
143-
Some(quesname) => match closest_named_problem(&problems, quesname) {
144-
Some(p) => p,
145-
None => 1,
146-
},
142+
match m.get_one::<String>("name") {
143+
Some(quesname) => closest_named_problem(&problems, quesname).unwrap_or(1),
147144
None => {
148145
// Pick random without specify id
149146
let problem = &problems[rand::thread_rng().gen_range(0..problems.len())];
@@ -190,7 +187,7 @@ fn closest_named_problem(problems: &Vec<Problem>, lookup_name: &str) -> Option<i
190187
let mut table: Vec<usize> = vec![0; (max_name_size + 1) * (lookup_name.len() + 1)];
191188

192189
// this is guaranteed because of the earlier max None propegation
193-
assert!(problems.len() > 0);
190+
assert!(!problems.is_empty());
194191
let mut max_score = 0;
195192
let mut current_problem = &problems[0];
196193
for problem in problems {
@@ -204,7 +201,7 @@ fn closest_named_problem(problems: &Vec<Problem>, lookup_name: &str) -> Option<i
204201

205202
if this_score > max_score {
206203
max_score = this_score;
207-
current_problem = &problem;
204+
current_problem = problem;
208205
}
209206
}
210207

@@ -213,7 +210,7 @@ fn closest_named_problem(problems: &Vec<Problem>, lookup_name: &str) -> Option<i
213210

214211
// Longest commong subsequence DP approach O(nm) space and time. Table must be at least
215212
// (text1.len() + 1) * (text2.len() + 1) length or greater and is mutated every call
216-
fn longest_common_subsequence(table: &mut Vec<usize>, text1: &str, text2: &str) -> usize {
213+
fn longest_common_subsequence(table: &mut [usize], text1: &str, text2: &str) -> usize {
217214
assert!(table.len() >= (text1.len() + 1) * (text2.len() + 1));
218215
let height: usize = text1.len() + 1;
219216
let width: usize = text2.len() + 1;

src/cmds/stat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl Command for StatCommand {
8181
);
8282

8383
// lines
84-
for (i, l) in vec![(easy, easy_ac), (medium, medium_ac), (hard, hard_ac)]
84+
for (i, l) in [(easy, easy_ac), (medium, medium_ac), (hard, hard_ac)]
8585
.iter()
8686
.enumerate()
8787
{

src/config/cookies.rs

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! Cookies in config
2-
use std::str::FromStr;
3-
42
use serde::{Deserialize, Serialize};
3+
use std::{
4+
fmt::{self, Display},
5+
str::FromStr,
6+
};
57

68
#[derive(Clone, Debug, Deserialize, Serialize)]
79
pub enum LeetcodeSite {
@@ -22,12 +24,14 @@ impl FromStr for LeetcodeSite {
2224
}
2325
}
2426

25-
impl ToString for LeetcodeSite {
26-
fn to_string(&self) -> String {
27-
match self {
28-
LeetcodeSite::LeetcodeCom => "leetcode.com".to_string(),
29-
LeetcodeSite::LeetcodeCn => "leetcode.cn".to_string(),
30-
}
27+
impl Display for LeetcodeSite {
28+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29+
let s = match self {
30+
LeetcodeSite::LeetcodeCom => "leetcode.com",
31+
LeetcodeSite::LeetcodeCn => "leetcode.cn",
32+
};
33+
34+
write!(f, "{s}")
3135
}
3236
}
3337

@@ -49,8 +53,12 @@ impl Default for Cookies {
4953
}
5054
}
5155

52-
impl std::string::ToString for Cookies {
53-
fn to_string(&self) -> String {
54-
format!("LEETCODE_SESSION={};csrftoken={};", self.session, self.csrf)
56+
impl Display for Cookies {
57+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58+
write!(
59+
f,
60+
"LEETCODE_SESSION={};csrftoken={};",
61+
self.session, self.csrf
62+
)
5563
}
5664
}

src/config/storage.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Storage {
6565
self.scripts = Some("scripts".into());
6666
}
6767

68-
let p = PathBuf::from(root).join(&self.scripts.ok_or(Error::NoneError)?);
68+
let p = PathBuf::from(root).join(self.scripts.ok_or(Error::NoneError)?);
6969
if !PathBuf::from(&p).exists() {
7070
std::fs::create_dir(&p)?
7171
}

src/helper.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ mod filter {
8787
ids.iter().for_each(|x| {
8888
map.insert(x.to_string(), true).unwrap_or_default();
8989
});
90-
ps.retain(|x| map.get(&x.id.to_string()).is_some());
90+
91+
ps.retain(|x| map.contains_key(&x.id.to_string()));
9192
Ok(())
9293
}
9394
}

src/plugins/chrome.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use anyhow::anyhow;
33
use diesel::prelude::*;
44
use keyring::Entry;
55
use openssl::{hash, pkcs5, symm};
6-
use std::collections::HashMap;
6+
use std::{collections::HashMap, fmt::Display};
77

88
/// LeetCode Cookies Schema
99
mod schema {
@@ -34,9 +34,13 @@ pub struct Ident {
3434
session: String,
3535
}
3636

37-
impl std::string::ToString for Ident {
38-
fn to_string(&self) -> String {
39-
format!("LEETCODE_SESSION={};csrftoken={};", self.session, self.csrf)
37+
impl Display for Ident {
38+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39+
write!(
40+
f,
41+
"LEETCODE_SESSION={};csrftoken={};",
42+
self.session, self.csrf
43+
)
4044
}
4145
}
4246

@@ -64,7 +68,7 @@ pub fn cookies() -> Result<Ident> {
6468
debug!("Chrome Cookies path is {:?}", &p);
6569
let mut conn = cache::conn(p.to_string_lossy().to_string());
6670
let res = cookies
67-
.filter(host_key.like(format!("#{}", ccfg.site.to_string())))
71+
.filter(host_key.like(format!("#{}", ccfg.site)))
6872
.load::<Cookies>(&mut conn)
6973
.expect("Loading cookies from google chrome failed.");
7074

src/plugins/leetcode.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,13 @@ impl LeetCode {
8686
json.insert("variables", r#"{"slug": "$slug"}"#.replace("$slug", slug));
8787
json.insert(
8888
"query",
89-
vec![
90-
"query getTopicTag($slug: String!) {",
89+
["query getTopicTag($slug: String!) {",
9190
" topicTag(slug: $slug) {",
9291
" questions {",
9392
" questionId",
9493
" }",
9594
" }",
96-
"}",
97-
]
95+
"}"]
9896
.join("\n"),
9997
);
10098

@@ -151,31 +149,27 @@ impl LeetCode {
151149
json.insert("operationName", "daily".to_string());
152150
json.insert(
153151
"query",
154-
vec![
155-
"query daily {",
152+
["query daily {",
156153
" activeDailyCodingChallengeQuestion {",
157154
" question {",
158155
" questionFrontendId",
159156
" }",
160157
" }",
161-
"}",
162-
]
158+
"}"]
163159
.join("\n"),
164160
);
165161
}
166162
config::LeetcodeSite::LeetcodeCn => {
167163
json.insert("operationName", "questionOfToday".to_string());
168164
json.insert(
169165
"query",
170-
vec![
171-
"query questionOfToday {",
166+
["query questionOfToday {",
172167
" todayRecord {",
173168
" question {",
174169
" questionFrontendId",
175170
" }",
176171
" }",
177-
"}",
178-
]
172+
"}"]
179173
.join("\n"),
180174
);
181175
}
@@ -201,8 +195,7 @@ impl LeetCode {
201195
let mut json: Json = HashMap::new();
202196
json.insert(
203197
"query",
204-
vec![
205-
"query getQuestionDetail($titleSlug: String!) {",
198+
["query getQuestionDetail($titleSlug: String!) {",
206199
" question(titleSlug: $titleSlug) {",
207200
" content",
208201
" stats",
@@ -213,8 +206,7 @@ impl LeetCode {
213206
" metaData",
214207
" translatedContent",
215208
" }",
216-
"}",
217-
]
209+
"}"]
218210
.join("\n"),
219211
);
220212

@@ -232,7 +224,7 @@ impl LeetCode {
232224
json: Some(json),
233225
mode: Mode::Post,
234226
name: "get_problem_detail",
235-
url: self.conf.sys.urls.graphql.into(),
227+
url: self.conf.sys.urls.graphql,
236228
}
237229
.send(&self.client)
238230
.await

src/pym.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn exec(module: &str) -> Result<Vec<String>> {
1616

1717
// pygil
1818
Python::with_gil(|py| {
19-
let pym = PyModule::from_code(py, &script, "plan.py", "plan")?;
19+
let pym = PyModule::from_code_bound(py, &script, "plan.py", "plan")?;
2020
pym.getattr("plan")?.call1((sps, stags))?.extract()
2121
})
2222
.map_err(Into::into)

0 commit comments

Comments
 (0)