提交 cd510b33 编写于 作者: A Alex Crichton

std: Remove the get() method from RefCell wrappers

This method has been entirely obsoleted by autoderef, so there's no reason for
its existence.
上级 e233a43f
......@@ -176,8 +176,7 @@ pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, 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 @@ fn drop(&mut self) {
}
}
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 @@ fn drop(&mut self) {
}
}
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 @@ struct Cycle {
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 @@ struct List {
{
let mut a = a.borrow_mut();
a.get().next = Some(b);
a.next = Some(b);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册