Skip to content

Conversation

steveklabnik
Copy link
Contributor

No description provided.

src/doc/guide.md Outdated
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoah whaoh. this whole section shouldn't be. My filesystem has been screwy lately....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now right. Whoah.

@huonw
Copy link
Contributor

huonw commented Jul 5, 2014

I think this reasonable fine, although it doesn't mention (there's no particular need to mention them now if you have a plan):

  • name bindings (possibly incl. mut x)
  • nested patterns
  • pattern matching on tuples, structs or tuple structs (not hugely useful at the top level, but very useful as nested patterns inside enums etc.)

Also, some things that could be mentioned at some point, but haven't got enough background:

  • ref, ref mut patterns for binding a name as a reference into the matchee (these are what make pattern matching in Rust actually workable & performant)
  • box and & patterns for matching through pointers (well, only Box atm) and references respectively.

@steveklabnik
Copy link
Contributor Author

Yeah, the last two really needs pointers.

This isn't intended to be super exhaustive, so I left off name bindings on purpose. I haven't decided when to put in nested patterns, but it seems like a good plan for when I talk about Result. Matching on those other things seems good since I just talked about them.

src/doc/guide.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/becuase/because

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thank you.

@steveklabnik
Copy link
Contributor Author

@huonw on the three:

  • pattern matching on tuples, structs or tuple structs: I think I want to cover this when I talk about Option, because that's when I've found it most useful.

Can you think of a decent example of these two? I haven't used them enough. I do think they should be covered here.

  • name bindings (possibly incl. mut x)
  • nested patterns

@sfackler
Copy link
Member

sfackler commented Jul 8, 2014

@steveklabnik here's on example of a place I've used a nested pattern:

match r.read(buf) {
    Ok(bytes) => { /* process buf */ }
    Err(IoError { kind: EndOfFile, .. }) => { /* bail out */ }
    Err(err) => { /* handle error */ }
}

@steveklabnik
Copy link
Contributor Author

@sfackler hmmm, interesting. That uses too many details I haven't talked about already, maybe that means it's a good candidate to put later in the guide.

@steveklabnik
Copy link
Contributor Author

After thinking about it, this is good to go for now. I'm actually going to have to introduce Option a bit earlier than I want, and so I have plans to add the other match stuff, but this should land first.

@brson r?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to write the failing code here, so the readers can try it out and experience the error for themselves.

@bors bors closed this Jul 15, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 21, 2023
…=lnicola

minor : Deunwrap generate_derive

rust-lang#15398 subtask 1. Since the editing closure has arms, I did something *experimental* ( in this case just a clever term for bad code ) to bypass creating an `Option` but I am ready to change this.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 22, 2025
…t-lang#15434)

A type with escaping bound vars cannot be wrapped in a dummy binder
during size computation.

Fixes rust-lang/rust-clippy#15429

changelog: [`zero_sized_hashmap_values`]: fix ICE in types with escaping
lifetimes

r? Jarcho

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

- [Beta
nomination](rust-lang/rust-clippy#15434 (comment))
by [samueltardieu](https://github.com/samueltardieu)

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
bors pushed a commit that referenced this pull request Sep 11, 2025
)

A type with escaping bound vars cannot be wrapped in a dummy binder
during size computation.

Fixes rust-lang/rust-clippy#15429

changelog: [`zero_sized_hashmap_values`]: fix ICE in types with escaping
lifetimes

r? Jarcho

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

- [Beta
nomination](rust-lang/rust-clippy#15434 (comment))
by [samueltardieu](https://github.com/samueltardieu)

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
MabezDev pushed a commit to esp-rs/rust that referenced this pull request Oct 3, 2025
…t-lang#15434)

A type with escaping bound vars cannot be wrapped in a dummy binder
during size computation.

Fixes rust-lang/rust-clippy#15429

changelog: [`zero_sized_hashmap_values`]: fix ICE in types with escaping
lifetimes

r? Jarcho

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

- [Beta
nomination](rust-lang/rust-clippy#15434 (comment))
by [samueltardieu](https://github.com/samueltardieu)

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants