Update if-let.md

Calling if-let a combination of if and let is confusing, as some may be led to believe that it's a literal combination, instead of syntactic sugar added to the language as a convenience.  What's there to stop someone from thinking if-let is just if and let together?  

I do think this article does a good job of implying what's really going on; however, I was only able to notice this after I had begun to understand if/while-let statements, courtesy of the Rust IRC chat.  

Basically, this article lacks the clarity and explicitness an inexperienced programmer like me needs in order to understand the contents fully.  This is shown by my inability to understand the if-let concept from this page of the Book alone.  

I think convenience, sugar, and (if-let != if + let) should all be made mention of in a clear, explicit manner. I lack confidence in my understanding of this issue, so I wrote just enough to hopefully get my thoughts across.
This commit is contained in:
bluecereal 2016-12-16 22:28:27 -05:00 committed by GitHub
parent d250169cb5
commit 4495f7e51e

View File

@ -1,7 +1,9 @@
% if let
`if let` allows you to combine `if` and `let` together to reduce the overhead
of certain kinds of pattern matches.
`if let` is a figurative combination of `if` and `let`. `if let` does not literally
mean `if` + `let` to the compiler; it has its own special meaning,which was added for
convenience and as a way to reduce the overhead of certain kinds of pattern matches.
For example, lets say we have some sort of `Option<T>`. We want to call a function
on it if its `Some<T>`, but do nothing if its `None`. That looks like this: