-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
feat: Add box1.rs exercise #409
feat: Add box1.rs exercise #409
Conversation
info.toml
Outdated
|
||
Step 2 | ||
Creating an empty list should be fairly straightforward (hint: peek at the assertions). | ||
For a non-empty list keep in mind that wee want to use our Cons "list builder". |
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.
wee -> we
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 spot, macbook butterfly keyboard 😅 . I'll correct this and put the hints through Grammarly
|
||
// Do not change these | ||
assert_eq!(List::Nil, empty_list); | ||
assert_ne!(empty_list, non_empty_list); |
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.
This is a clever way of requiring a non-Nil list variant without giving away the solution!
This is a good entry-level exercise with good accompanying explanations. Based on prior Rustlings feedback, the main complaint might be that its solution is inside the Rust book. Personally, I believe this is fine since it gives people an opportunity to play with the ideas in the book. |
Thank you for the feedback! On the first point: I know the book readily provides the solution, but I thought this could serve as an easy intro to Boxes, and you still get the satisfaction of solving it by reading the book in my view as well :). On the second point: I hadn't noticed that before because I tested with |
I tried it out, and it works! Perhaps someone more involved with the project could weigh in on whether it is okay for the solution to be in the Book? In my opinion, adding this as-is is an improvement to what already exists. (A possible variant would be using a linked list rather than a cons list, e.g. at the bottom of https://rust-unofficial.github.io/too-many-lists/first-layout.html.) PS - @fmoko gave you the thumbs up on .idea, so I'm assuming that's the official go-ahead :D |
Yep, go ahead! |
Thanks, added now! What's the next step for this? |
Will look at this ASAP |
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.
LGTM
thanks everyone, I had a good time writing this and using rustlings in general. This was my first ever contribution to an open-source project 😁 |
Having completed all of the existing exercises, I noticed there wasn't one with the
Box
type.Although this exercise alone might not completely solve #403, I think it's a start 🦀 .