Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Problem增加return type字段
  • Loading branch information
songyzh committed Feb 2, 2020
commit cbfeffbcd533a8a56e9d91a8a3ce45c112fc0da5
18 changes: 17 additions & 1 deletion src/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub fn get_problem(frontend_question_id: u32) -> Option<Problem> {
sample_test_case: resp.data.question.sample_test_case,
difficulty: problem.difficulty.to_string(),
question_id: problem.stat.frontend_question_id,
return_type: serde_json::from_str(&resp.data.question.meta_data.return_info.type_name).unwrap(),
});
}
}
Expand All @@ -64,6 +65,7 @@ pub struct Problem {
pub sample_test_case: String,
pub difficulty: String,
pub question_id: u32,
pub return_type: String,
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -111,7 +113,21 @@ struct Question {
#[serde(rename = "sampleTestCase")]
sample_test_case: String,
#[serde(rename = "metaData")]
meta_data: String,
meta_data: MetaData,
}

#[derive(Debug, Serialize, Deserialize)]
struct MetaData {
name:String,
params: String,
return_info: ReturnInfo,
}

#[derive(Debug, Serialize, Deserialize)]
struct ReturnInfo {
#[serde(rename = "type")]
type_name: String,
params: String,
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down