Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `box_patterns` feature #29641
Comments
aturon
added
T-lang
B-unstable
labels
Nov 5, 2015
This comment has been minimized.
This comment has been minimized.
|
Will it be possible to use box patterns with smart pointers? |
This comment has been minimized.
This comment has been minimized.
|
Odd question: I've seen a few |
This comment has been minimized.
This comment has been minimized.
|
Types will be written |
This comment has been minimized.
This comment has been minimized.
|
Oh, I understand that in general, |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
jadbox
commented
Apr 26, 2017
•
|
Are 'Box patterns' enabled, without flags, on Nightly yet? |
This comment has been minimized.
This comment has been minimized.
|
@jadbox No. Unless someone missed something, this issue would be closed if they were. rustc 1.18.0-nightly (2b4c911 2017-04-25) error: box pattern syntax is experimental (see issue #29641)
--> a.rs:2:9
|
2 | let box a = Box::new(1);
| ^^^^^
|
= help: add #![feature(box_patterns)] to the crate attributes to enable
error: aborting due to previous error |
This comment has been minimized.
This comment has been minimized.
jadbox
commented
Apr 26, 2017
|
thanks @SimonSapin What's left to do on the feature before it can be considered 'stable' enough for nightly? |
This comment has been minimized.
This comment has been minimized.
This is related to box syntax more generally, so the questions around that need to be resolved first. |
glaebhoerl
referenced this issue
Jun 12, 2017
Merged
Match Ergonomics Using Default Binding Modes #2005
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
SimonSapin
referenced this issue
Aug 8, 2017
Open
Extend `&pattern` to general `Deref` implementation. #2099
Ms2ger
referenced this issue
Sep 20, 2017
Open
Tracking: Unstable Rust feature gates used by Servo #5286
This comment has been minimized.
This comment has been minimized.
deontologician
commented
Jan 25, 2018
•
|
This is really critical to matching recursive enums. I have some code like: match act {
Subcondition(box Always(act)) => simplify(act),
Subcondition(box cond) => Subcondition(Box::new(simplify(cond))),
otherwise => otherwise
}And basically, I'm stuck on nightly. Is this box pattern syntax really super tied to the placement syntax in the other issues that are also using the Maybe changing the keyword from |
This comment has been minimized.
This comment has been minimized.
|
As discussed on the RFC for default binding modes in So you could do things like: let foo = Rc::new(Some(true)); // or Box, or Arc, or ...
match &foo {
Some(b) => { /* b is of type `&bool` here */ }
None => { ... }
}There may or may not be complications around things like |
This comment has been minimized.
This comment has been minimized.
|
Would it also be possible for |
This comment has been minimized.
This comment has been minimized.
|
I would prefer to deprecate |
This comment has been minimized.
This comment has been minimized.
|
I don't think binding modes are as expressive on their own, though. We would need something beyond the RFC in order to fully remove Or did you mean forcing people to add |
This comment has been minimized.
This comment has been minimized.
|
There was some discussion about these things on the RFC, but I don't really remember it. In either case, this is getting into the weeds; I think the part that's important for now is just that the use case that was going to be satisfied by |
This comment has been minimized.
This comment has been minimized.
deontologician
commented
Jan 26, 2018
|
@glaebhoerl So the best place to discuss this is default binding modes then? Is there much momentum there? |
This comment has been minimized.
This comment has been minimized.
|
@deontologician Yes I'd think so (go ahead and drop a line there if the use case is important to you). Default binding modes itself (based on the tracking issue) is implemented but has a ways to go before stabilization; there hasn't been any "official" discussion about doing the thing I described, but a few people have seemed to agree that it seems like a promising direction to move in. |
This comment has been minimized.
This comment has been minimized.
deontologician
commented
Jan 26, 2018
|
Yeah, looks like discussion of that part is picked up in rust-lang/rfcs#2099 which doesn't have an RFC yet. I'll move my focus there, thanks! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jcotton42
commented
Mar 11, 2019
|
Bumping this since it's been 11 months and I'm also interested in this (don't have any specific use case, just interested) |
aturon commentedNov 5, 2015
Box patterns were gated by RFC 469.