-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Adds a simple exercise for structures #163
Conversation
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.
thank you!
@bors r+ |
📌 Commit 9b92aa0 has been approved by |
Adds a simple exercise for structures Thanks for rustlings! Here's a small contribution in return.
☀️ Test successful - checks-travis |
I'm having an issue with this. I'm not sure if correct answers should be discussed here or not. It may also be because of my lack of experience. #[test]
fn unit_structs() {
// TODO: Instantiate a unit struct!
let green = ColorUnitStruct;
if let ColorUnitStruct = green {
assert!(true);
} else {
assert!(false);
}
} Results in error[E0162]: irrefutable if-let pattern
--> exercises/structs/structs1.rs:41:16
|
41 | if let ColorUnitStruct = green {
| ^^^^^^^^^^^^^^^ irrefutable pattern |
@emiller88 would you mind sharing that entire test? |
@briankung Sorry I should have mentioned it's in the |
@emiller88 I understand, sorry I must have had a brain fart (or there was an edit to your comment) but I didn't think I had the entirety of your failing test case. What version of Rust are you using? |
@briankung |
Weird. Well, seeing as I'm a Rust newbie myself, I can't really say why this doesn't work on your machine. It does seem to make sense - after all once it knows the type of You can try throwing a |
I was using
|
Odd. Unlikely to be related, but what OS are you using? I'm also confused why the allow attribute doesn't work since it works in the playground. And your test looks like the below? #[test]
#[allow(irrefutable_let_patterns)]
fn unit_structs() {
// ...
} |
Yes it did, the |
I can't recreate the error so I can't reliably fix it, but how would you
like to proceed?
…On Tue, Jun 11, 2019, 6:11 PM Edmund Miller ***@***.***> wrote:
Yes it did, the #[allow(irrefutable_let_patterns)] works in the
playground however without it the test still fails
<https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b94d896c7d1c19918dc58edceae3ff77>
so I think it's an issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#163?email_source=notifications&email_token=AAVUNR3PUD5DHTHB3ID6SS3P2AWEDA5CNFSM4HPUOF52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXOYLZI#issuecomment-501056997>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAVUNR55ARFSHDPV65DT27LP2AWEDANCNFSM4HPUOF5Q>
.
|
Does this playground work for you? It's exactly what's in the |
The tests pass with a warning. I think the playground output should not
vary by client machine.
…On Tue, Jun 11, 2019, 6:44 PM Edmund Miller ***@***.***> wrote:
Does this playground work for you? It's exactly what's in the
exercises/structs/structs1.rs
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b94d896c7d1c19918dc58edceae3ff77
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#163?email_source=notifications&email_token=AAVUNR23HGCSTIA4DRXTDFLP2A2EVA5CNFSM4HPUOF52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXO2HVY#issuecomment-501064663>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAVUNRZKIH2U6MRV657UWMTP2A2EVANCNFSM4HPUOF5Q>
.
|
Ah I didn't see it was a warning in the playground. When it runs with a test(At least in my version) the warning turns into an error when the test runs. If it's just unique to my version I think we're good here. |
I am using Facing the same issue as @emiller88 above. This doesn't appear to be machine specific. I feel we should modify the test around this, else 'rustlings watch' will not function. |
This doesn't error after updating to rustc 1.35.0 (3c235d560 2019-05-20) |
It seems odd that it would error in one but not the other. I think the test should change, it's just especially odd that something like an irrefutable let pattern would change from version to version of Rust. @ksceriath does the
I'm trying it myself, as well. Hopefully it does the same for rustlings. |
@emiller88 and @ksceriath I've opened #179, please take a look and see if those changes work for you. Sorry for the inconvenience! |
…r=komaeda Fixes the irrefutable let pattern warning in `structs1.rs` PR #163 accidentally introduced an error using some versions of the Rust compiler where the compiler would (rightly!) complain about an irrefutable let pattern. I have no idea why this did not occur in all versions of the compiler, but here is a way around it.
@briankung This works with 1.32 / 1.35. Thank you! |
@briankung Works on both for me as well thanks for fixing it! |
going through the tests one by one, i am wondering why this is the first that has no help to scroll down to. even the link to the docs makes this exercise suddenly much harder than the previous |
…r=komaeda Fixes the irrefutable let pattern warning in `structs1.rs` PR rust-lang/rustlings#163 accidentally introduced an error using some versions of the Rust compiler where the compiler would (rightly!) complain about an irrefutable let pattern. I have no idea why this did not occur in all versions of the compiler, but here is a way around it.
Adds a simple exercise for structures Thanks for rustlings! Here's a small contribution in return.
Adds a simple exercise for structures Thanks for rustlings! Here's a small contribution in return.
…tructs1, r=komaeda Fixes the irrefutable let pattern warning in `structs1.rs` PR rust-lang#163 accidentally introduced an error using some versions of the Rust compiler where the compiler would (rightly!) complain about an irrefutable let pattern. I have no idea why this did not occur in all versions of the compiler, but here is a way around it.
…r=komaeda Fixes the irrefutable let pattern warning in `structs1.rs` PR rust-lang/rustlings#163 accidentally introduced an error using some versions of the Rust compiler where the compiler would (rightly!) complain about an irrefutable let pattern. I have no idea why this did not occur in all versions of the compiler, but here is a way around it.
Adds a simple exercise for structures Thanks for rustlings! Here's a small contribution in return.
…tructs1, r=komaeda Fixes the irrefutable let pattern warning in `structs1.rs` PR rust-lang#163 accidentally introduced an error using some versions of the Rust compiler where the compiler would (rightly!) complain about an irrefutable let pattern. I have no idea why this did not occur in all versions of the compiler, but here is a way around it.
Thanks for rustlings! Here's a small contribution in return.