test: Fix fallout of removing get()

This commit is contained in:
Alex Crichton 2014-03-20 22:06:51 -07:00
parent 6a7fd8cfa5
commit 76f0b1ad1f
8 changed files with 12 additions and 12 deletions

View File

@ -24,7 +24,7 @@ pub struct alist<A,B> {
pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
let mut data = lst.data.borrow_mut();
data.get().push(Entry{key:k, value:v});
(*data).push(Entry{key:k, value:v});
}
pub fn alist_get<A:Clone + 'static,
@ -34,7 +34,7 @@ pub fn alist_get<A:Clone + 'static,
-> B {
let eq_fn = lst.eq_fn;
let data = lst.data.borrow();
for entry in data.get().iter() {
for entry in (*data).iter() {
if eq_fn(entry.key.clone(), k.clone()) {
return entry.value.clone();
}

View File

@ -42,5 +42,5 @@ fn main()
let w = v.clone();
let b = v.deref();
let mut b = b.borrow_mut();
b.get().v.set(w.clone());
b.v.set(w.clone());
}

View File

@ -13,6 +13,6 @@ use std::cell::RefCell;
fn main() {
let m = RefCell::new(0);
let mut b = m.borrow_mut();
let b1 = b.get();
let b2 = b.get(); //~ ERROR cannot borrow
let b1 = &mut *b;
let b2 = &mut *b; //~ ERROR cannot borrow
}

View File

@ -15,6 +15,6 @@ fn main() {
let p;
{
let b = m.borrow();
p = b.get(); //~ ERROR `b` does not live long enough
p = &*b; //~ ERROR `b` does not live long enough
}
}

View File

@ -13,6 +13,6 @@ use std::cell::RefCell;
pub fn main() {
let name = RefCell::new("rust");
let what = RefCell::new("rocks");
let msg = format!("{name:?} {:?}", what.borrow().get(), name=name.borrow().get());
let msg = format!("{name:?} {:?}", &*what.borrow(), name=&*name.borrow());
assert_eq!(msg, ~"&\"rust\" &\"rocks\"");
}

View File

@ -42,8 +42,8 @@ impl to_str for Tree {
fn to_str_(&self) -> ~str {
let Tree(t) = *self;
let this = t.borrow();
let (l, r) = (this.get().left, this.get().right);
let val = &this.get().val;
let (l, r) = (this.left, this.right);
let val = &this.val;
format!("[{}, {}, {}]", val.to_str_(), l.to_str_(), r.to_str_())
}
}
@ -64,6 +64,6 @@ pub fn main() {
{
let Tree(t1_) = t1;
let mut t1 = t1_.borrow_mut();
t1.get().left = Some(t2); // create cycle
t1.left = Some(t2); // create cycle
}
}

View File

@ -38,6 +38,6 @@ pub fn main() {
let v = empty_pointy();
{
let mut vb = v.borrow_mut();
vb.get().a = p(v);
vb.a = p(v);
}
}

View File

@ -35,6 +35,6 @@ pub fn main() {
let v = empty_pointy();
{
let mut vb = v.borrow_mut();
vb.get().a = p(v);
vb.a = p(v);
}
}