-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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 refcell1 exercise #1779
base: main
Are you sure you want to change the base?
Conversation
I like the idea of teaching about RefCells, but I feel like this exercise would have to be somewhat more sophisticated... I'd like people to be able to see the difference of behaviour between the normal compile-time borrow check and what RefCell provides, maybe a more engaging exercise format could be converting something that's impossible with normal borrowing rules to using RefCell? |
Thanks for taking a look @shadows-withal. I agree the example could be more sophisticated and I will look into updating it. Potentially following the Rust Book more closely is a good direction to take. |
Signed-off-by: denton <[email protected]>
@shadows-withal I have updated the example to use the I think since this may be the first introduction to RefCell a user has, it's simplicity is a feature. Happy to adjust as necessary. |
The exercise teaches the usage of |
I see -- that's fair. At the risk of making the example more convoluted I can update the example to provide a scenario where refcell is a necessity. |
I am a very new maintainer. Let's wait for the feedback from @shadows-withal first :D |
I think exercises on Cell, RefCell, RwLock and Mutex in sequence would be nice. I remember there was a video that explained when these smart pointers become useful quite nicely. It explains why and when interior mutability is required. PS: I'm sorry if exercises on these features have already been discussed and decided. I just finished all exercises and was wondering why these weren't included. BTW doing god's work, you guys! Thank you so much for creating this project! |
Adds a basic exercise to introduce the concept of a
RefCell
. This API is not necessarily for beginners but is useful to have knowledge of.