-
Notifications
You must be signed in to change notification settings - Fork 33
Fix the iterators example. #199
New issue
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
Conversation
Deploying ferrous-systems-rust-exercises with
|
| Latest commit: |
4910285
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c9b3921e.ferrous-systems-rust-exercises.pages.dev |
| Branch Preview URL: | https://fixes.ferrous-systems-rust-exercises.pages.dev |
Simplified the solution and tidied up some of the exercise text whilst I was here. Closes #197
|
Force pushed after I found some typos I'd made. Also, I replaced "turbo fish" with "turbofish" as per the docs. |
| .fold(0, |acc, elem| acc + elem); | ||
| // Also works | ||
| //.sum::<i32>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simply put .sum(); here. Unlike filter and map that are popular, fold is not used too often. Half of Itertools methods are fold variants with more descriptive methods. May as well call sum because we work with numbers here. Turbofish is not needed, because there's i32 on line 9 already.
| .fold(0, |acc, elem| acc + elem); | |
| // Also works | |
| //.sum::<i32>(); | |
| .sum(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Also updated the text above to match, and the solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11 | let result = reader.lines()
| ^^^^^^
...
15 | .sum();
| --- type must be known at this point
oops
|
I have appeased the type checker. |
Simplified the solution and tidied up some of the exercise text whilst I was here.
Closes #197