mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
test: Fix fallout of removing get()
This commit is contained in:
parent
6a7fd8cfa5
commit
76f0b1ad1f
@ -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();
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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\"");
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user