Skip to content
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

Port and Chan methods should take &mut self #5372

Closed
brson opened this issue Mar 14, 2013 · 9 comments
Closed

Port and Chan methods should take &mut self #5372

brson opened this issue Mar 14, 2013 · 9 comments
Labels
A-trait-system Area: Trait system C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Milestone

Comments

@brson
Copy link
Contributor

brson commented Mar 14, 2013

As well as other functions and methods on pipes. They are mutating the pipe.

@Thiez
Copy link
Contributor

Thiez commented Mar 14, 2013

As far as I am aware, it is currently not possible for a closure to capture a mutable. So a closure could never obtain a mutable reference to a Chan or Port, which means it would never be able to call, for example, channel.send(&mut self, x). Of course there are tricks such as transmute_mut, but perhaps it would be better for this issue to remain unfixed until closures can capture mutable references.

@brson
Copy link
Contributor Author

brson commented Mar 14, 2013

I'm still not totally sure I think this is a good idea. There are some types, like ARC, that pretend to be immutable even though they are implemented with mutation. For ARC we need it because they behave as if they are Const and we want them to be usable in Const structures. I am not sure if a similar argument can be made for pipes.

@brson
Copy link
Contributor Author

brson commented May 16, 2013

Nominating backward compat

@graydon
Copy link
Contributor

graydon commented May 16, 2013

already on the backwards-compatible milestone

@bblum
Copy link
Contributor

bblum commented Jul 10, 2013

Even if ports/chans had &mut self methods, it wouldn't let them fulfill Freeze, because Cell has #[no_freeze]. It would let you call them with &-pointers, which wouldn't be unsound due to implementation details, but I think is undesirable anyway.

@thestinger
Copy link
Contributor

Tagging as an RFC to get some more input here. It's not a design choice isolated to these types.

@bblum
Copy link
Contributor

bblum commented Sep 3, 2013

the mutable capture problem will be solved en passant with once closures or with macro-trait closures. basically we just have to wait until the dust settles on the ultimate fate of closures, and then make the change here.

@pnkfelix
Copy link
Member

cc me

@alexcrichton
Copy link
Member

Closing, it was decided by #10830 that they shouldn't.

bors added a commit to rust-lang-ci/rust that referenced this issue May 2, 2020
move redundant_pub_crate to nursery

cc rust-lang#5369
changelog: none
calebcartwright pushed a commit to calebcartwright/rust that referenced this issue Jun 23, 2022
* add doc_comment_code_block_width configuration

* updated config docu

* Updated docu and changed tests to config folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

7 participants