Skip to content
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

Fix instructions(steps) for conversions/from_str exercice #626

Merged
merged 1 commit into from
Jan 21, 2021

Conversation

jfchevrette
Copy link
Contributor

The steps currently tell the user to return an error but the tests check for panic.

This updates the instructions to make it clearer that if the extraction/parsing fails, a panic should be raised

Copy link
Contributor

@AbdouSeck AbdouSeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jfchevrette, thanks for suggesting changes to this exercise. The changes you're adding will not work. The implementation of a trait should never panic. It should always return a Result.

The #[should_panic] directives you see in the test cases are there to make sure what when .unwrap() is used on an erroneous Result, the program should panic. The tests themselves can be updated to avoid the usage the .unwrap() method and to remove the somewhat confusing #[should_panic] directives. I am more than happy to review and approve this PR if you take that on.

Please let me know if you have any questions.

Thanks,
Abdou

@jfchevrette
Copy link
Contributor Author

@AbdouSeck Thank you for the detailed response and for being welcoming and patient with new contributors. This is my first contribution to the rust ecosystem and it is nice to see such kindness.

I have changed my PR following your guidance. I hope it meets expectations now. What I did was remove the #[should_panic] and replace the function body with an assert! and the tests now use is_err() to validate whether or not the returned value is an error.

I also changed the steps instructions a bit again. I mostly added clarification/hints at the newer tests which were added recently trailing_comma and trailing_comma_and_some_string

Please let me know what you think and advise if you feel there's additional changes needed. Thanks!

Copy link
Contributor

@AbdouSeck AbdouSeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfchevrette the tests look great. Thanks for updating them and for adding clarifications to the instructions.

@AbdouSeck AbdouSeck merged commit 15a79cf into rust-lang:main Jan 21, 2021
@shadows-withal
Copy link
Member

@all-contributors please add @jfchevrette for content and code

@allcontributors
Copy link
Contributor

@fmoko

I've put up a pull request to add @jfchevrette! 🎉

ppp3 pushed a commit to ppp3/rustlings that referenced this pull request May 23, 2022
Fix instructions(steps) for conversions/from_str exercice
dmoore04 pushed a commit to dmoore04/rustlings that referenced this pull request Sep 11, 2022
Fix instructions(steps) for conversions/from_str exercice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants