Skip to content

Commit 651c668

Browse files
committed
fix: deprcated warnings
1 parent b3086a5 commit 651c668

File tree

7 files changed

+74
-22
lines changed

7 files changed

+74
-22
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ path = "src/bin/lc.rs"
44

55
[package]
66
name = "leetcode-cli"
7-
version = "0.2.14"
8-
authors = ["clearloop <udtrokia@163.com>"]
7+
version = "0.2.15"
8+
authors = ["clearloop <cdr.today@foxmail.com>"]
99
edition = "2018"
1010
description = "Leet your code in command-line."
1111
repository = "https://github.com/clearloop/leetcode-cli"

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
[![LICENSE](https://img.shields.io/crates/l/leetcode-cli.svg)](https://choosealicense.com/licenses/mit/)
66

77
## Contributors
8-
+ [@Raees678](https://github.com/Raees678)
98
+ [@ldm0](https://github.com/ldm0)
9+
+ [@Raees678](https://github.com/Raees678)
1010
+ [@clearloop](https://github.com/clearloop)
1111

1212
## Features
@@ -27,8 +27,7 @@ cargo install leetcode-cli
2727
**Please make sure you have logined in `leetcode.com` with `chrome`**, more info plz checkout [this](#cookies)
2828

2929
```sh
30-
leetcode 0.2.14
31-
clearloop <udtrokia@163.com>
30+
leetcode 0.2.15
3231
May the Code be with You 👻
3332

3433
USAGE:

SUBSTRATE.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Pluging Substrate to leetcode-cli
2+
3+
Fired by decentralize system and POS consensus, I just got a plan of great daring, **it would be nice** pluging a blockchain into leetcode-cli, for fun!
4+
5+
### What can `blockchain` offer for leetcode-cli?
6+
7+
The direct scene is the interaction of `leetcode-cli` users, **friends can make some secret contests themselves**, for example, Alice and Bob arrange that they will keep coding in next week, and the winner is the folk who solves more problems(no loser no game, no winner no life), how to implement this with blockchain system?
8+
9+
1. Both of them stake part of their treasury into `leetcode-cli`'s blockchain treasury pool before the contest begin.
10+
2. At the deadline date, loser's treasury in pool will fly to the winners' wallet, unfortunately, the result will record in `leetcode-cli`'s blockchain system as well, if Bob lose, he lost really, besides, `leetcode-cli` will help him remember this.
11+
12+
It's quite fun in some way, student times, friendships, coding memories...**Do you remember the Saturday Gigs?**
13+
14+
15+
## How to make this come true?
16+
17+
Just joined a [substrate][ss] project last days, it is possible pluging `substrate` into `leetcode-cli`, eha, well, no questions, **just do it!**
18+
19+
## Instructions
20+
21+
Here are some instructions waiting to serve you, if you want to join this **lonely heart club** barehanded.
22+
23+
**Q1: What is blockchain?**
24+
25+
A blockchain is a chain of blocks.
26+
27+
Well done, we just grasp the subtlety of the ultimate meaning of life, universe, and everything —— a towel and a guide-book is all we need.
28+
29+
## Serious FAQ
30+
31+
404.
32+
33+
## Milestones
34+
35+
> In progress.
36+
37+
1. Construct the basic substrate in `leetcode-cli`'s repo as a side-project.
38+
2. Initialize treasuries which can never run out for everybody, yep, yet another digital world for Ricks and Morties.
39+
3. Abstract several contracts for different contest games.
40+
4. Complete the interation between `leetcode-cli` and `substrate`.
41+
42+
## Contributes
43+
44+
If you got some ideas about this march, or my poor English, just change this file, or comment below, any way, come as you are
45+
46+
[ss]: https://substrate.dev/
47+

src/cache/mod.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,20 @@ impl Cache {
186186
&self,
187187
run: Run,
188188
rfid: i32,
189-
testcase: Option<String>
189+
testcase: Option<String>,
190190
) -> Result<(HashMap<&'static str, String>, [String; 2]), Error> {
191191
trace!("pre run code...");
192192
use crate::helper::code_path;
193193
use std::fs::File;
194194
use std::io::Read;
195195

196196
let p = &self.get_problem(rfid)?;
197+
if p.desc.is_empty() {
198+
trace!("Problem description does not exist, pull desc and exec again...");
199+
self.get_question(rfid)?;
200+
return self.pre_run_code(run, rfid, testcase);
201+
}
202+
197203
let d: Question = serde_json::from_str(&p.desc)?;
198204
let conf = &self.0.conf;
199205
let mut json: HashMap<&'static str, String> = HashMap::new();
@@ -210,8 +216,7 @@ impl Cache {
210216
json.insert("name", p.name.to_string());
211217
match testcase {
212218
Some(case) => json.insert("data_input", case),
213-
_ => json.insert("data_input", d.case)
214-
219+
_ => json.insert("data_input", d.case),
215220
};
216221

217222
let url = match run {
@@ -257,7 +262,12 @@ impl Cache {
257262
}
258263

259264
/// Exec problem filter —— Test or Submit
260-
pub fn exec_problem(&self, rfid: i32, run: Run, testcase: Option<String>) -> Result<VerifyResult, Error> {
265+
pub fn exec_problem(
266+
&self,
267+
rfid: i32,
268+
run: Run,
269+
testcase: Option<String>,
270+
) -> Result<VerifyResult, Error> {
261271
trace!("Exec problem filter —— Test or Submit");
262272
let pre = self.pre_run_code(run.clone(), rfid, testcase)?;
263273
let json = pre.0;

src/cli.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ use crate::{
77
err::Error,
88
flag::{Debug, Flag},
99
};
10-
use clap::{App, AppSettings, crate_name, crate_authors, crate_version};
10+
use clap::{crate_name, crate_version, App, AppSettings};
1111

1212
/// Get maches
1313
pub fn main() -> Result<(), Error> {
1414
let m = App::new(crate_name!())
15-
.author(crate_authors!("\n"))
1615
.version(crate_version!())
1716
.about("May the Code be with You 👻")
1817
.subcommands(vec![

src/err.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Errors in leetcode-cli
22
use colored::Colorize;
3-
use std::error::Error as StdError;
43
use std::fmt;
54

65
/// Error enum
@@ -48,29 +47,28 @@ impl std::fmt::Debug for Error {
4847
// network
4948
impl std::convert::From<reqwest::Error> for Error {
5049
fn from(err: reqwest::Error) -> Self {
51-
Error::NetworkError(err.description().to_string())
50+
Error::NetworkError(err.to_string())
5251
}
5352
}
5453

5554
// nums
5655
impl std::convert::From<std::num::ParseIntError> for Error {
5756
fn from(err: std::num::ParseIntError) -> Self {
58-
Error::ParseError(err.description().to_string())
57+
Error::ParseError(err.to_string())
5958
}
6059
}
6160

6261
// sql
6362
impl std::convert::From<diesel::result::Error> for Error {
6463
fn from(err: diesel::result::Error) -> Self {
65-
Error::CacheError(err.description().to_string())
64+
Error::CacheError(err.to_string())
6665
}
6766
}
6867

6968
// serde
7069
impl std::convert::From<serde_json::error::Error> for Error {
7170
fn from(err: serde_json::Error) -> Self {
72-
error!("{:?}", &err);
73-
Error::ParseError(err.description().to_string())
71+
Error::ParseError(err.to_string())
7472
}
7573
}
7674

@@ -79,7 +77,7 @@ impl std::convert::From<toml::de::Error> for Error {
7977
fn from(err: toml::de::Error) -> Self {
8078
Error::ParseError(format!(
8179
"{}, {}{}{}{}{}{}{}{}",
82-
err.description().to_string(),
80+
err.to_string(),
8381
"Parse config file failed, ",
8482
"leetcode-cli has just generated a new leetcode.toml at ",
8583
"~/.leetcode/leetcode_tmp.toml,".green().bold().underline(),
@@ -94,14 +92,14 @@ impl std::convert::From<toml::de::Error> for Error {
9492

9593
impl std::convert::From<toml::ser::Error> for Error {
9694
fn from(err: toml::ser::Error) -> Self {
97-
Error::ParseError(err.description().to_string())
95+
Error::ParseError(err.to_string())
9896
}
9997
}
10098

10199
// io
102100
impl std::convert::From<std::io::Error> for Error {
103101
fn from(err: std::io::Error) -> Self {
104-
Error::CacheError(err.description().to_string())
102+
Error::CacheError(err.to_string())
105103
}
106104
}
107105

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
//! **Please make sure you have logined in `leetcode.com` with `chrome`**, more info plz checkout [this](#cookies)
2424
//!
2525
//! ```sh
26-
//! leetcode 0.2.14
27-
//! clearloop <udtrokia@163.com>
26+
//! leetcode 0.2.15
2827
//! May the Code be with You 👻
2928
//!
3029
//! USAGE:

0 commit comments

Comments
 (0)