Skip to content

Commit 720571f

Browse files
committed
chore(app): bump version to 0.4.7
1 parent 85b7f55 commit 720571f

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
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: 1 addition & 1 deletion
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.6"
7+
version = "0.4.7"
88
authors = ["clearloop <[email protected]>"]
99
edition = "2021"
1010
description = "Leetcode command-line interface in rust."

src/cmds/pick.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl Command for PickCommand {
144144
Some(quesname) => closest_named_problem(&problems, quesname).unwrap_or(1),
145145
None => {
146146
// Pick random without specify id
147-
let problem = &problems[rand::thread_rng().gen_range(0..problems.len())];
147+
let problem = &problems[rand::rng().random_range(0..problems.len())];
148148
problem.fid
149149
}
150150
}
@@ -155,7 +155,7 @@ impl Command for PickCommand {
155155
.or(daily_id)
156156
.unwrap_or_else(|| {
157157
// Pick random without specify id
158-
let problem = &problems[rand::thread_rng().gen_range(0..problems.len())];
158+
let problem = &problems[rand::rng().random_range(0..problems.len())];
159159
problem.fid
160160
})
161161
}

src/pym.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! Seems like some error exists now, welocome pr to fix this : )
44
use crate::{cache::Cache, helper::load_script, Result};
55
use pyo3::prelude::*;
6+
use std::ffi::CString;
67

78
/// Exec python scripts as filter
89
pub fn exec(module: &str) -> Result<Vec<String>> {
@@ -16,7 +17,10 @@ pub fn exec(module: &str) -> Result<Vec<String>> {
1617

1718
// pygil
1819
Python::with_gil(|py| {
19-
let pym = PyModule::from_code_bound(py, &script, "plan.py", "plan")?;
20+
let script_cstr = CString::new(script.as_str())?;
21+
let filename_cstr = CString::new("plan.py")?;
22+
let module_name_cstr = CString::new("plan")?;
23+
let pym = PyModule::from_code(py, &script_cstr, &filename_cstr, &module_name_cstr)?;
2024
pym.getattr("plan")?.call1((sps, stags))?.extract()
2125
})
2226
.map_err(Into::into)

0 commit comments

Comments
 (0)