1. 11
    Rustlings functions4: Declaring the return type of a function
    43s

Rustlings functions4: Declaring the return type of a function

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

README for this exercise.

Chris Biscardi: [0:00] In functions4, let's reverse what we've been doing and take a look at the error message first, expected type, found '{'. At line 14, function sale_price, price is an i32. There's an arrow here where Rust expected a type. If we find line 14, we can see that sale_price takes a parameter that is an i32. It doesn't have a return value even though we've used the arrow here.

[0:27] If we remember back to our if statement, we can see that we're implicitly returning price - 10 or price - 3. In that case, we can probably use an i32 since that's what the parameter is and we're operating with integers on it. Note our test is passed.

egghead
egghead
~ 16 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today