Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 46afa69

Browse files
committed
feat: Refactoring
1 parent 73e1865 commit 46afa69

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

‎src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub enum Errors {
99
#[error("ApiError(`{0}`)")]
1010
ApiError(String),
1111
#[error("Sendrror(`{0}`)")]
12-
SendError(String)
12+
SendError(String),
1313
}
1414

1515
impl std::convert::From<Errors> for io::Error {

‎src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl UserApi {
230230
})
231231
}
232232

233-
pub asyncfn find_profile(&self, username: &str) -> UserProfile {
233+
pub fn find_profile(&self, username: &str) -> UserProfile {
234234
UserProfile {
235235
client: self.client.clone(),
236236
username: String::from(username),
@@ -325,4 +325,4 @@ pub enum ProgrammingLanguage {
325325
Dart,
326326
Pandas,
327327
React,
328-
}
328+
}

‎src/problem_actions.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use crate::{
1212
subm_show::SubmList,
1313
test_send::{TestCase, TestCaseResp, TestExecutionResult},
1414
Descryption, Rate,
15-
}, ProgrammingLanguage,
15+
},
16+
ProgrammingLanguage,
1617
};
1718

1819
#[derive(Debug)]
@@ -64,13 +65,20 @@ impl Problem {
6465
if status.state == "SUCCESS" {
6566
return Ok(status);
6667
} else if status.state == "FAILURE" {
67-
return Err(Errors::SendError("Sent code failure. Err may be occured by Unsupported lang for this problem".into()));
68+
return Err(Errors::SendError(
69+
"Sent code failure. Err may be occured by Unsupported lang for this problem"
70+
.into(),
71+
));
6872
}
6973
tokio::time::sleep(Duration::from_secs(1)).await;
7074
}
7175
}
7276

73-
pub async fn send_subm(&self, lang: ProgrammingLanguage, code: &str) -> Result<SubmExecutionResult, Errors> {
77+
pub async fn send_subm(
78+
&self,
79+
lang: ProgrammingLanguage,
80+
code: &str,
81+
) -> Result<SubmExecutionResult, Errors> {
7482
let lang = Self::lang_converter(lang);
7583
let json_data = serde_json::to_string(&SubmissionCase {
7684
question_id: self.full_data.data.question.questionId.clone(),
@@ -104,7 +112,10 @@ impl Problem {
104112
if status.state == "SUCCESS" {
105113
return Ok(status);
106114
} else if status.state == "FAILURE" {
107-
return Err(Errors::SendError("Sent code failure. Err may be occured by Unsupported lang for this problem".into()));
115+
return Err(Errors::SendError(
116+
"Sent code failure. Err may be occured by Unsupported lang for this problem"
117+
.into(),
118+
));
108119
}
109120
tokio::time::sleep(Duration::from_secs(1)).await;
110121
}

‎src/profile.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl MyProfile {
3737
prev_list_name: &str,
3838
new_list_name: &str,
3939
) -> Result<&MyProfile, Errors> {
40-
let id_hash = if let Some(id) = Self::get_id_hash(&self, prev_list_name).await {
40+
let id_hash = if let Some(id) = Self::get_id_hash(&self, prev_list_name) {
4141
id
4242
} else {
4343
return Err(Errors::ApiError("Provided name doesn't found".into()));
@@ -59,7 +59,7 @@ impl MyProfile {
5959
}
6060

6161
pub async fn set_public(&self, list_name: &str) -> Result<&MyProfile, Errors> {
62-
let id_hash = if let Some(id) = Self::get_id_hash(&self, list_name).await {
62+
let id_hash = if let Some(id) = Self::get_id_hash(&self, list_name) {
6363
id
6464
} else {
6565
return Err(Errors::ApiError(
@@ -83,7 +83,7 @@ impl MyProfile {
8383
}
8484

8585
pub async fn set_private(&self, list_name: &str) -> Result<&MyProfile, Errors> {
86-
let id_hash = if let Some(id) = Self::get_id_hash(&self, list_name).await {
86+
let id_hash = if let Some(id) = Self::get_id_hash(&self, list_name) {
8787
id
8888
} else {
8989
return Err(Errors::ApiError(
@@ -107,7 +107,7 @@ impl MyProfile {
107107
}
108108

109109
pub async fn get_share_url(&self, list_name: &str) -> Result<String, Errors> {
110-
let id_hash = if let Some(id) = Self::get_id_hash(&self, list_name).await {
110+
let id_hash = if let Some(id) = Self::get_id_hash(&self, list_name) {
111111
id
112112
} else {
113113
return Err(Errors::ApiError(
@@ -119,7 +119,7 @@ impl MyProfile {
119119
}
120120

121121
pub async fn delete_list(&self, list_name: &str) -> Result<&MyProfile, Errors> {
122-
let id_hash = if let Some(id) = Self::get_id_hash(&self, list_name).await {
122+
let id_hash = if let Some(id) = Self::get_id_hash(&self, list_name) {
123123
id
124124
} else {
125125
return Err(Errors::ApiError(
@@ -135,7 +135,7 @@ impl MyProfile {
135135
Ok(self)
136136
}
137137

138-
asyncfn get_id_hash(&self, list_name: &str) -> Option<(String, bool)> {
138+
fn get_id_hash(&self, list_name: &str) -> Option<(String, bool)> {
139139
for favourite in &self.fav_lists.data.favoritesLists.allFavorites {
140140
if favourite.name == list_name.to_string() {
141141
return Some((favourite.idHash.clone(), favourite.isPublicFavorite.clone()));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /