Skip to content

Commit de7b8c3

Browse files
committed
chore(workspace): bumps edition to 2024
1 parent 2b6f375 commit de7b8c3

File tree

8 files changed

+31
-26
lines changed

8 files changed

+31
-26
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ path = "src/bin/lc.rs"
66
name = "leetcode-cli"
77
version = "0.4.8"
88
authors = ["clearloop <tianyi.gc@gmail.com>"]
9-
edition = "2021"
9+
edition = "2024"
1010
description = "Leetcode command-line interface in rust."
1111
repository = "https://github.com/clearloop/leetcode-cli"
1212
license = "MIT"
@@ -50,4 +50,4 @@ features = ["gzip", "json"]
5050
pym = ["pyo3"]
5151

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

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/cmds/completions.rs

Lines changed: 11 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,20 @@ 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>(
47+
generator: G,
48+
cmd: &mut ClapCommand,
49+
) -> Result<String, Error> {
4550
let mut v: Vec<u8> = Vec::new();
4651
let name = cmd.get_name().to_string();
47-
generate(gen, cmd, name, &mut v);
52+
generate(generator, cmd, name, &mut v);
4853
Ok(String::from_utf8(v)?)
4954
}
5055

src/cmds/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ impl Command for TestCommand {
6767
async fn handler(m: &ArgMatches) -> Result<()> {
6868
use crate::cache::{Cache, Run};
6969
use crate::helper::code_path;
70-
use notify::{Config as NotifyConfig, Event, RecommendedWatcher, RecursiveMode, Watcher};
70+
use notify::{Config as NotifyConfig, RecommendedWatcher, RecursiveMode, Watcher};
7171
use std::path::Path;
7272
use std::sync::mpsc::channel;
7373
use std::time::{Duration, Instant};
7474

7575
let cache = Cache::new()?;
76-
7776
let daily = m.get_one::<bool>("daily").unwrap_or(&false);
7877
let daily_id = if *daily {
7978
Some(cache.get_daily_problem_id().await?)

src/config/code.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ fn default_submission() -> String {
1111
SUBMISSION_DEFAULT.into()
1212
}
1313

14-
fn is_default_pick(t: &String) -> bool {
14+
fn is_default_pick(t: &str) -> bool {
1515
t == PICK_DEFAULT
1616
}
1717

1818
fn is_default_submission(t: &String) -> bool {
1919
t == SUBMISSION_DEFAULT
2020
}
2121

22-
fn is_default_string(t: &String) -> bool {
22+
fn is_default_string(t: &str) -> bool {
2323
t.is_empty()
2424
}
2525
fn is_default_bool(t: &bool) -> bool {

src/config/cookies.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ impl Cookies {
7878
if let Ok(session) = std::env::var(LEETCODE_SESSION_ENV) {
7979
self.session = session;
8080
}
81-
if let Ok(site) = std::env::var(LEETCODE_SITE_ENV) {
82-
if let Ok(leetcode_site) = LeetcodeSite::from_str(&site) {
83-
self.site = leetcode_site;
84-
}
81+
if let Ok(site) = std::env::var(LEETCODE_SITE_ENV)
82+
&& let Ok(leetcode_site) = LeetcodeSite::from_str(&site)
83+
{
84+
self.site = leetcode_site;
8585
}
8686
self
8787
}

src/helper.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,9 @@ mod html {
154154
});
155155

156156
let frag = Html::parse_fragment(&res);
157-
158-
let res = frag
159-
.root_element()
157+
frag.root_element()
160158
.text()
161-
.fold(String::new(), |acc, e| acc + e);
162-
163-
res
159+
.fold(String::new(), |acc, e| acc + e)
164160
}
165161
}
166162
}
@@ -191,7 +187,7 @@ mod file {
191187
}
192188
}
193189

194-
use crate::{cache::models::Problem, Error};
190+
use crate::{Error, cache::models::Problem};
195191

196192
/// Generate test cases path by fid
197193
pub fn test_cases_path(problem: &Problem) -> crate::Result<String> {

0 commit comments

Comments
 (0)