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

Add "collections" exercises #572

Merged
merged 2 commits into from
Oct 30, 2020
Merged

Add "collections" exercises #572

merged 2 commits into from
Oct 30, 2020

Conversation

sazid
Copy link
Contributor

@sazid sazid commented Oct 26, 2020

Since Vec and HashMap are two fundamental data structures that are used often in every programming languages, I added 4 new exercises for them.

  • The "collections" exercises has been added after the "modules" and before the "macros" exercises.
  • vec1.rs and vec2.rs for exercises related to Vectors. First exercise focuses on declaration of vectors and second exercise focuses on iteration and mutability.
  • hashmap1.rs and hashmap2.rs exercises for HashMaps. First exercise focuses on declaration and insertion. Second exercise focuses on entry() API.

Open to any improvements or suggestions!

@AbdouSeck
Copy link
Contributor

Hi @sazid, thanks for these exercises. They're very useful. I have two suggestions:

  1. Would you consider squashing your commits so that you end up with 2 commits: 1 commit for the HashMap exercises and 1 commit for the Vec exercises?

  2. I see that you're converting the keys of hash maps into vectors just to get the length/size of the hash maps, but the HashMap type already offers .len() which can take care of that. For instance, this line of code could have been shortened with assert!(basket.len() >= 3). Also, I have noticed other ways of shortening lines of code. I made additional comments above.

Other than these two things, there is really nothing else I can comment on.

Thanks,
Abdou

@AbdouSeck AbdouSeck self-assigned this Oct 30, 2020
@AbdouSeck AbdouSeck added S-waiting-on-author Status: Waiting on issue/PR author A-exercises Area: Exercises labels Oct 30, 2020
@sazid
Copy link
Contributor Author

sazid commented Oct 30, 2020

Hi @sazid, thanks for these exercises. They're very useful. I have two suggestions:

  1. Would you consider squashing your commits so that you end up with 2 commits: 1 commit for the HashMap exercises and 1 commit for the Vec exercises?
  2. I see that you're converting the keys of hash maps into vectors just to get the length/size of the hash maps, but the HashMap type already offers .len() which can take care of that. For instance, this line of code could have been shortened with assert!(basket.len() >= 3). Also, I have noticed other ways of shortening lines of code. I made additional comments above.

Other than these two things, there is really nothing else I can comment on.

Thanks,
Abdou

  1. Will do.
  2. I completely forgot about the HashMap's len() method! I'll adjust them as well and push changes.

Thanks for your suggestions!

@sazid
Copy link
Contributor Author

sazid commented Oct 30, 2020

@AbdouSeck I've resolved the issues and also squashed into two separate commits.

Thanks.

@AbdouSeck
Copy link
Contributor

@sazid looks good to me. Thank you!

@fmoko I think this can be merged.

Abdou

Copy link
Member

@shadows-withal shadows-withal left a comment

Choose a reason for hiding this comment

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

Thanks for the exercises, and @AbdouSeck for the review!

@shadows-withal shadows-withal merged commit 7abfbd2 into rust-lang:main Oct 30, 2020
@shadows-withal
Copy link
Member

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

@allcontributors
Copy link
Contributor

@fmoko

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

ppp3 pushed a commit to ppp3/rustlings that referenced this pull request May 23, 2022
dmoore04 pushed a commit to dmoore04/rustlings that referenced this pull request Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exercises Area: Exercises S-waiting-on-author Status: Waiting on issue/PR author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants