Fix code snippet to discard a pointer in "naughty pointer" #281
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix guide for versions 0.14 & 0.13
Fix typo in code snippet. Discarding the variable should be
_ = &y;
instead of_ = y;
.Replace
var x: u16 = 0;
withvar x: u16 = 5; x -= 5;
. Else the compiler complains witherror: local variable is never mutated
. The updated example also highlights that the compiler is able to detect the value of x is not 0 after a mutation.Note that
const x: u16 = 0
would have resulted in a different error message instead ofpanic: cast causes pointer to be null
.resolves: #275