-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Rename PatUniq to PatBox and extend support to arbitrary smart pointers #13910
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
Comments
Would you mind commenting on what "extend support to arbitrary smart pointers" means? I did the rename, but I imagine that wasn't the most important part of this? |
Something like this should also work: let foo = Rc::new(3);
match foo {
box n => println!("{}", n),
} That should also work for things like |
I'll look into this. |
@jakub- do you have someone mentoring you on it? It will probably tie into our allocator story, which remains to be 100% settled. I don't want to investing a lot of effort into a path that we are not planning on going down. |
@pnkfelix Well, for now I was just going to make the box pattern compile down to a deref for arbitrary pointers rather than Box<> pointers specifically. I'd imagine the Deref trait is going to stay regardless of the allocator changes? |
Should |
@jakub- oh sorry, I misread the title and was thinking of the |
Is there an RFC for this? If not, I don't mind writing one and maybe starting work on this. |
@Manishearth Please go ahead if you're interested! The reason I hadn't gotten around to writing an RFC is my serious doubts around if allowing box patterns for arbitrary pointers is really feasible and/or a good idea. Essentially, for it to work the But I'm looking forward to your proposal and maybe it's workable! |
To be fair, what I described above is already a problem for the borrow checker in that without the special knowledge of particular smart pointers (like |
Actually, I don't have enouigh knowledge of the compiler to be able to write a good RfC on this, after probing the issue, sorry :/ |
Could |
Triage: box patterns are now feature gated. |
Triage: box patterns are still gated, but doing a
I'm guessing this is used somewhere, but maybe under a different name or something? |
@steveklabnik I think the rename happened, but not the extension to arbitrary |
I think we can close this. The extension to arbitrary "smart pointers" etc feels like an RFC issue to me. |
Yup.
The text was updated successfully, but these errors were encountered: