-
Notifications
You must be signed in to change notification settings - Fork 508
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
Specify refutability of patterns in let and if let #660
Conversation
src/expressions/if-expr.md
Outdated
pattern, an `=` and a [scrutinee] expression. If the value of the scrutinee | ||
matches the pattern, the corresponding block will execute. Otherwise, flow | ||
proceeds to the following `else` block if it exists. Like `if` expressions, | ||
refutable pattern, an `=` and a [scrutinee] expression. If the value of the |
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.
The pattern in if let
can be irrefutable.
Of course! Sorry. I misunderstood the definition of refutable to encompass
irrefutable. If I may that change, is this a fix to which you are open?
…On Wed, Aug 28, 2019, 4:53 AM Mazdak Farrokhzad ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/expressions/if-expr.md
<#660 (comment)>
:
> @@ -53,9 +53,9 @@ assert_eq!(y, "Bigger");
An `if let` expression is semantically similar to an `if` expression but in
place of a condition expression it expects the keyword `let` followed by a
-pattern, an `=` and a [scrutinee] expression. If the value of the scrutinee
-matches the pattern, the corresponding block will execute. Otherwise, flow
-proceeds to the following `else` block if it exists. Like `if` expressions,
+refutable pattern, an `=` and a [scrutinee] expression. If the value of the
The pattern in if let can be irrefutable.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#660>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACCP2CT2AXDMSK3KPDIE7QDQGY4J3ANCNFSM4IQ7VDRA>
.
|
This appears to contradict:
https://doc.rust-lang.org/book/ch18-02-refutability.html
…On Wed, Aug 28, 2019, 5:47 AM Will Hawkins ***@***.***> wrote:
Of course! Sorry. I misunderstood the definition of refutable to encompass
irrefutable. If I may that change, is this a fix to which you are open?
On Wed, Aug 28, 2019, 4:53 AM Mazdak Farrokhzad ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In src/expressions/if-expr.md
> <#660 (comment)>
> :
>
> > @@ -53,9 +53,9 @@ assert_eq!(y, "Bigger");
>
> An `if let` expression is semantically similar to an `if` expression but in
> place of a condition expression it expects the keyword `let` followed by a
> -pattern, an `=` and a [scrutinee] expression. If the value of the scrutinee
> -matches the pattern, the corresponding block will execute. Otherwise, flow
> -proceeds to the following `else` block if it exists. Like `if` expressions,
> +refutable pattern, an `=` and a [scrutinee] expression. If the value of the
>
> The pattern in if let can be irrefutable.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#660>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ACCP2CT2AXDMSK3KPDIE7QDQGY4J3ANCNFSM4IQ7VDRA>
> .
>
|
The book is wrong. |
Ok. Should we reconcile the two?
…On Wed, Aug 28, 2019, 6:14 AM Mazdak Farrokhzad ***@***.***> wrote:
This appears to contradict:
https://doc.rust-lang.org/book/ch18-02-refutability.html
The book is wrong.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#660>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACCP2CS7U7V3LOF7JOPGF2TQGZFXXANCNFSM4IQ7VDRA>
.
|
Thanks for working on this with me!
…On Wed, Aug 28, 2019, 6:15 AM Will Hawkins ***@***.***> wrote:
Ok. Should we reconcile the two?
On Wed, Aug 28, 2019, 6:14 AM Mazdak Farrokhzad ***@***.***>
wrote:
> This appears to contradict:
> https://doc.rust-lang.org/book/ch18-02-refutability.html
>
> The book is wrong.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#660>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ACCP2CS7U7V3LOF7JOPGF2TQGZFXXANCNFSM4IQ7VDRA>
> .
>
|
Yes we should. Please file a bug against the book's repo. |
Corresponds to rust-lang/book#2039 which updates the Book. I hope that this is a helpful PR. @Centril |
Specify that patterns in 1. 'if let' and 'while let' expressions are either refutable or irrefutable 2. 'let' and 'for' statements are always irrefutable
Closing to reopen because I am expanding the scope slightly. |
Specify that patterns in 'if let' expressions are refutable
while patterns in 'let' statements are irrefutable.