Skip to content

Remove RefCell::get #13182

Closed
Closed
@erickt

Description

@erickt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions