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

Remove RefCell::get #13182

Closed
erickt opened this issue Mar 28, 2014 · 3 comments · Fixed by #13301
Closed

Remove RefCell::get #13182

erickt opened this issue Mar 28, 2014 · 3 comments · Fixed by #13301

Comments

@erickt
Copy link
Contributor

erickt commented Mar 28, 2014

I'm not sure if this deserves a proper RFC or not, but since I consider this to be a bug I figure it makes sense here :)

I just ran into a bug where I assumed that RefCell::get follows our convention of .get() methods returning a &T pointer, and I was surprised to find that RefCell::get is actually:

impl<T:Clone> RefCell<T> {
    pub fn get(&self) -> T {
        (*self.borrow()).clone()
    }
    ...
}

It's surprising, and it can be easily replaced with x.borrow().clone() if a copy is actually needed. I propose we just remove it.

@alexcrichton
Copy link
Member

I believe that this was originally implemented to ease the transition from @mut to @RefCell, but with autoderef I don't believe that this is necessary any more. I'd vote for removing it.

@sfackler
Copy link
Member

set should go as well.

@nikomatsakis
Copy link
Contributor

👍 but cc #13159

@bors bors closed this as completed in eae2652 Apr 4, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 8, 2024
Remove some miscellaneous `#[allow]`s

Some were unneeded, others were removed by fixing/removing the thing they allow

changelog: none
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 a pull request may close this issue.

4 participants