Skip to content

Commit f98896a

Browse files
author
Bastian Gruber
committed
Update code example
1 parent d5cbe03 commit f98896a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ch_03/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ impl Reject for InvalidId {}
5252

5353
async fn get_questions() -> Result<impl warp::Reply, warp::Rejection> {
5454
let question = Question::new(
55-
QuestionId::from_str("1").expect("No id provided"),
55+
QuestionId::from_str("A").expect("No id provided"),
5656
"First Question".to_string(),
5757
"Content of question".to_string(),
5858
Some(vec!("faq".to_string())),
5959
);
6060

61-
match question.id.0.is_empty() {
62-
true => {
61+
match question.id.0.parse::<i32>() {
62+
Err(_) => {
6363
Err(warp::reject::custom(InvalidId))
6464
},
65-
false => {
65+
Ok(_) => {
6666
Ok(warp::reply::json(
6767
&question
6868
))

0 commit comments

Comments
 (0)