We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The book has in Listing 3.7:
Listing 3.7
let new_course = Course { tutor_id: new_course.tutor_id, course_id: Some(course_count_for_user + 1), course_name: new_course.course_name.clone(), posted_time: Some(Utc::now().naive_utc()), };
Rust compiler returns with an error:
course_id: Some(course_count_for_user + 1), ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `usize`
Since the .count returns a usize and course_id was defined as an Option of i32 (i.e. Option<i32>):
.count
usize
course_id
Option
i32
Option<i32>
let course_count_for_user = app_state ... .count(); // returns a usize
The value for course_id needs to be changed to:
course_id: Some((course_count_for_user + 1) as i32),
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The book has in
Listing 3.7
:Rust compiler returns with an error:
Since the
.count
returns ausize
andcourse_id
was defined as anOption
ofi32
(i.e.Option<i32>
):The value for
course_id
needs to be changed to:The text was updated successfully, but these errors were encountered: