Skip to content

Commit 1223a7b

Browse files
committed
Update Cargo dependencies and toolchain configuration, formatting and
fixing rust code.
1 parent 3bec9e8 commit 1223a7b

File tree

18 files changed

+711
-513
lines changed

18 files changed

+711
-513
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,48 @@ path = "src/bin/lc.rs"
55
[package]
66
name = "leetcode-cli"
77
version = "0.4.6"
8-
authors = ["clearloop <tianyi.gc@gmail.com>"]
8+
authors = ["clearloop <tianyi.gc@gmail.com>", "yousiki <you.siki@outlook.com>"]
99
edition = "2021"
10-
description = "Leetcode command-line interface in rust."
11-
repository = "https://github.com/clearloop/leetcode-cli"
10+
description = "Leetcode command-line interface in rust. Forked by yousiki."
11+
repository = "https://github.com/yousiki/leetcode-cli"
1212
license = "MIT"
1313
documentation = "https://docs.rs/leetcode_cli"
14-
homepage = "https://github.com/clearloop/leetcode-cli"
14+
homepage = "https://github.com/yousiki/leetcode-cli"
1515
keywords = ["cli", "games", "leetcode"]
1616
readme = './README.md'
1717

1818
[dependencies]
1919
async-trait = "0.1.88"
20-
tokio = { version = "1.44.2", features = ["full"] }
21-
clap = { version = "4.5.37", features = ["cargo"] }
20+
tokio = { version = "1.45.1", features = ["full"] }
21+
clap = { version = "4.5.40", features = ["cargo"] }
2222
colored = "3.0.0"
2323
dirs = "6.0.0"
24-
env_logger = "0.11.6"
24+
env_logger = "0.11.8"
2525
keyring = "3.6.2"
2626
log = "0.4.27"
27-
openssl = "0.10.72"
27+
openssl = "0.10.73"
2828
pyo3 = { version = "0.24.2", optional = true }
2929
rand = "0.9.1"
3030
serde = { version = "1.0.219", features = ["derive"] }
3131
serde_json = "1.0.140"
32-
toml = "0.8.22"
32+
toml = "0.8.23"
3333
regex = "1.11.1"
3434
scraper = "0.23.1"
3535
anyhow = "1.0.98"
36-
clap_complete = "4.5.48"
36+
clap_complete = "4.5.54"
3737
thiserror = "2.0.12"
3838
unicode-width = "0.2"
3939

4040
[dependencies.diesel]
41-
version = "2.2.10"
41+
version = "2.2.11"
4242
features = ["sqlite"]
4343

4444
[dependencies.reqwest]
45-
version = "0.12.15"
45+
version = "0.12.20"
4646
features = ["gzip", "json"]
4747

4848
[features]
4949
pym = ["pyo3"]
5050

5151
[target.'cfg(target_family = "unix")'.dependencies]
52-
nix = { version = "0.30.0", features = [ "signal" ] }
52+
nix = { version = "0.30.1", features = ["signal"] }

rust-toolchain.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
[toolchain]
22
channel = "stable"
3-
components = [
4-
"rustc",
5-
"cargo",
6-
"rustfmt",
7-
"clippy",
8-
"rust-analyzer",
9-
]
3+
components = ["cargo", "clippy", "rust-analyzer", "rustc", "rustfmt"]
104
profile = "minimal"

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
edition = "2021"
1+
edition = "2024"
22
tab_spaces = 4

src/cache/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ pub fn conn(p: String) -> SqliteConnection {
2222
}
2323

2424
/// Condition submit or test
25-
#[derive(Clone, Debug)]
26-
#[derive(Default)]
25+
#[derive(Clone, Debug, Default)]
2726
pub enum Run {
2827
Test,
2928
#[default]
3029
Submit,
3130
}
3231

33-
3432
/// Requests if data not download
3533
#[derive(Clone)]
3634
pub struct Cache(pub LeetCode);
@@ -188,7 +186,7 @@ impl Cache {
188186
Err(Error::CookieError)
189187
} else {
190188
Err(Error::PremiumError)
191-
}
189+
};
192190
}
193191
Some(true) => (),
194192
}

src/cache/models.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Leetcode data models
2-
use unicode_width::UnicodeWidthStr;
3-
use unicode_width::UnicodeWidthChar;
42
use super::schemas::{problems, tags};
53
use crate::helper::HTML;
64
use colored::Colorize;
75
use serde::{Deserialize, Serialize};
86
use serde_json::Number;
7+
use unicode_width::UnicodeWidthChar;
8+
use unicode_width::UnicodeWidthStr;
99

1010
/// Tag model
1111
#[derive(Clone, Insertable, Queryable, Serialize, Debug)]

src/cache/parser.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +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
19+
.as_str()?
20+
.split(' ')
21+
.next_back()?
22+
.parse::<i32>()
23+
.ok()?,
1924
};
2025

2126
problems.push(Problem {
@@ -132,7 +137,7 @@ pub fn user(v: Value) -> Option<Option<(String, bool)>> {
132137
pub use ss::ssr;
133138
/// string or squence
134139
mod ss {
135-
use serde::{de, Deserialize, Deserializer};
140+
use serde::{Deserialize, Deserializer, de};
136141
use std::fmt;
137142
use std::marker::PhantomData;
138143

src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Clap Commanders
22
use crate::{
33
cmds::{
4-
completion_handler, Command, CompletionCommand, DataCommand, EditCommand, ExecCommand,
5-
ListCommand, PickCommand, StatCommand, TestCommand,
4+
Command, CompletionCommand, DataCommand, EditCommand, ExecCommand, ListCommand,
5+
PickCommand, StatCommand, TestCommand, completion_handler,
66
},
77
err::Error,
88
flag::{Debug, Flag},

src/cmds/completions.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ use super::Command;
44
use crate::err::Error;
55
use async_trait::async_trait;
66
use clap::{Arg, ArgAction, ArgMatches, Command as ClapCommand};
7-
use clap_complete::{generate, Generator, Shell};
7+
use clap_complete::{Generator, Shell, generate};
88

99
/// Abstract shell completions command
1010
///
1111
/// ```sh
1212
/// Generate shell Completions
13-
13+
///
1414
/// USAGE:
1515
/// leetcode completions <shell>
16-
16+
///
1717
/// ARGUMENTS:
1818
/// <shell> [possible values: bash, elvish, fish, powershell, zsh]
1919
/// ```
@@ -36,15 +36,17 @@ impl Command for CompletionCommand {
3636
async fn handler(_m: &ArgMatches) -> Result<(), Error> {
3737
// defining custom handler to print the completions. Handler method signature limits taking
3838
// other params. We need &ArgMatches and &mut ClapCommand to generate completions.
39-
println!("Don't use this handler. Does not implement the functionality to print completions. Use completions_handler() below.");
39+
println!(
40+
"Don't use this handler. Does not implement the functionality to print completions. Use completions_handler() below."
41+
);
4042
Ok(())
4143
}
4244
}
4345

44-
fn get_completions_string<G: Generator>(gen: G, cmd: &mut ClapCommand) -> Result<String, Error> {
46+
fn get_completions_string<G: Generator>(g: G, cmd: &mut ClapCommand) -> Result<String, Error> {
4547
let mut v: Vec<u8> = Vec::new();
4648
let name = cmd.get_name().to_string();
47-
generate(gen, cmd, name, &mut v);
49+
generate(g, cmd, name, &mut v);
4850
Ok(String::from_utf8(v)?)
4951
}
5052

src/cmds/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Cache managger
22
use super::Command;
3-
use crate::{cache::Cache, helper::Digit, Error};
3+
use crate::{Error, cache::Cache, helper::Digit};
44
use async_trait::async_trait;
55
use clap::{Arg, ArgAction, ArgMatches, Command as ClapCommand};
66
use colored::Colorize;

0 commit comments

Comments
 (0)