std: Remove the get() method from RefCell wrappers
This method has been entirely obsoleted by autoderef, so there's no reason for its existence.
This commit is contained in:
parent
e233a43f5a
commit
cd510b3382
3 changed files with 6 additions and 27 deletions
|
@ -176,8 +176,7 @@ impl<T> RefCell<T> {
|
|||
/// Fails if the value is currently borrowed.
|
||||
#[inline]
|
||||
pub fn set(&self, value: T) {
|
||||
let mut reference = self.borrow_mut();
|
||||
*reference.get() = value;
|
||||
*self.borrow_mut() = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,23 +188,19 @@ impl<T:Clone> RefCell<T> {
|
|||
/// Fails if the value is currently mutably borrowed.
|
||||
#[inline]
|
||||
pub fn get(&self) -> T {
|
||||
let reference = self.borrow();
|
||||
(*reference.get()).clone()
|
||||
(*self.borrow()).clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> Clone for RefCell<T> {
|
||||
fn clone(&self) -> RefCell<T> {
|
||||
let x = self.borrow();
|
||||
RefCell::new(x.get().clone())
|
||||
RefCell::new(self.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Eq> Eq for RefCell<T> {
|
||||
fn eq(&self, other: &RefCell<T>) -> bool {
|
||||
let a = self.borrow();
|
||||
let b = other.borrow();
|
||||
a.get() == b.get()
|
||||
*self.borrow() == *other.borrow()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,14 +217,6 @@ impl<'b, T> Drop for Ref<'b, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'b, T> Ref<'b, T> {
|
||||
/// Retrieve an immutable reference to the stored value.
|
||||
#[inline]
|
||||
pub fn get<'a>(&'a self) -> &'a T {
|
||||
unsafe{ &*self.parent.value.get() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, T> Deref<T> for Ref<'b, T> {
|
||||
#[inline]
|
||||
fn deref<'a>(&'a self) -> &'a T {
|
||||
|
@ -250,14 +237,6 @@ impl<'b, T> Drop for RefMut<'b, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'b, T> RefMut<'b, T> {
|
||||
/// Retrieve a mutable reference to the stored value.
|
||||
#[inline]
|
||||
pub fn get<'a>(&'a mut self) -> &'a mut T {
|
||||
unsafe{ &mut *self.parent.value.get() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, T> Deref<T> for RefMut<'b, T> {
|
||||
#[inline]
|
||||
fn deref<'a>(&'a self) -> &'a T {
|
||||
|
|
|
@ -284,7 +284,7 @@ mod tests {
|
|||
|
||||
let a = Rc::new(Cycle { x: RefCell::new(None) });
|
||||
let b = a.clone().downgrade();
|
||||
*a.deref().x.borrow_mut().get() = Some(b);
|
||||
*a.deref().x.borrow_mut() = Some(b);
|
||||
|
||||
// hopefully we don't double-free (or leak)...
|
||||
}
|
||||
|
|
|
@ -471,7 +471,7 @@ mod test {
|
|||
|
||||
{
|
||||
let mut a = a.borrow_mut();
|
||||
a.get().next = Some(b);
|
||||
a.next = Some(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue