Skip to content

Commit 9b2632f

Browse files
chore(dep): bump the deps group with 9 updates (clearloop#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] <support@github.com> * chore(clippy): make clippy happy * chore(clippy): make clippy happy * chore(ver): bumps version to 0.4.4 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: clearloop <udtrokia@gmail.com> Co-authored-by: clearloop <tianyi.gc@gmail.com>
1 parent 13d5416 commit 9b2632f

File tree

13 files changed

+213
-135
lines changed

13 files changed

+213
-135
lines changed

Cargo.lock

Lines changed: 151 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 10 deletions
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 <tianyi.gc@gmail.com>"]
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

Lines changed: 2 additions & 5 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 5 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 19 additions & 11 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy