-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Update match-expressions.md #103
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
Conversation
The original code would always print "Unknown program name!".
|
Note that this allows multiple commands, and prints the message for each. So you can run:
|
|
Hi @snoopdougiedougie, thanks for spotting this.
Yeah, I think I didn't pick a super good example to be honest. Perhaps we can rework it to something which lends itself better to an interactive class. When teaching the class, I live code using the code on the slides (pages). Here it would be great to have a code snippet which both
Perhaps we can stay in the same theme and hard-code the arguments. We could then use Perhaps we can find a better program name to match against — perhaps we say that we're reimplementing |
|
Yeah, it's hard to find a good example for a class. You want something "real-world", but not too difficult. The problem with parsing the command line to show how match works isn't how you usually accept command-line options in Rust--you usually use Clap. |
True 😄 but I hope the students who take the class will forgive us for this. It would be cool to explain how to actually do it in a speaker note — I've just put up #107 which should help with that. |
|
#107
wire
…On Wed, Jan 4, 2023, 6:52 PM Martin Geisler ***@***.***> wrote:
works isn't how you usually accept command-line options in Rust--you
usually use Clap.
True 😄 but I hope the students who take the class will forgive us for
this. It would be cool to explain how to actually do it in a speaker note —
I've just put up #107
<#107> which should help
with that.
—
Reply to this email directly, view it on GitHub
<#103 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A437GHRKDW46L7G2KNQEKS3WQW2FHANCNFSM6AAAAAATP6FMMU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
mgeisler
left a comment
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.
Please update it to use a fixed vector instead — make pattern matching the focus, not command line shenanigans 😄
The call to as_deref is also something which raises questions every time I teach the class. We can either leave it and explain what it does in a note, or we can rework the example to make it unnecessary.
I'm of course also fine doing this myself, just let me know. We can close this PR and I'll put something else up eventually. |
|
Let's close this for now — I think the example should be rewritten to not use the arguments at all since that's just extra noise. |
The original code would always print "Unknown program name!".