-
Notifications
You must be signed in to change notification settings - Fork 30
Remove excess as_ref, as_mut and unwraps #7
Comments
Just a note about this: in part 8, in the heal function, I believe this is mistaken: |
Ah, good catch, thanks! So I planned to remove the |
All right, this commit should fix the healing issue: Thanks! |
I can give this a look, while the tutorial is still mostly fresh in my mind. If I removed the Copy trait wherever it appears, it should become clear where this isn't working correctly? I guess I should read up on the copy trait (lots of learning to do!) |
Yeah, so when you assign a value to another variable or say a function directly (i.e. not by a reference), it gets moved and you can't access it from the original place. You can see it nicely in this example: https://play.rust-lang.org/?gist=6124763952dcfdf8e932d94b18fc4894&version=stable&backtrace=0 So for example the healing potion bug you've discovered earlier was because the So yeah if you do dig into this, try to remove One more thing that's relevant: if you're pattern-matching an So for example this:
could have been written as: which I like less, hence this issue. |
This project has not been maintained for a few years. I'm closing all pull requests and issues before archiving the repo on github. Sorry I hadn't done this sooner! |
There's a few places where we could just match on
Some(ref mut something)
instead of callingas_mut
. And ideally, we should get rid of allunwraps
.The text was updated successfully, but these errors were encountered: