Move mutable::Mut to cell::RefCell

This commit is contained in:
Steven Fackler 2013-11-21 21:30:34 -08:00
parent c6ca9abcc6
commit bdfaf04bd5
11 changed files with 335 additions and 350 deletions

View file

@ -9,21 +9,21 @@
// except according to those terms.
use std::rc::Rc;
use std::mutable::Mut;
use std::cell::RefCell;
trait Foo
{
fn set(&mut self, v: Rc<Mut<A>>);
fn set(&mut self, v: Rc<RefCell<A>>);
}
struct B
{
v: Option<Rc<Mut<A>>>
v: Option<Rc<RefCell<A>>>
}
impl Foo for B
{
fn set(&mut self, v: Rc<Mut<A>>)
fn set(&mut self, v: Rc<RefCell<A>>)
{
self.v = Some(v);
}
@ -37,7 +37,7 @@ struct A
fn main()
{
let a = A {v: ~B{v: None} as ~Foo}; //~ ERROR cannot pack type `~B`, which does not fulfill `Send`
let v = Rc::from_send(Mut::new(a));
let v = Rc::from_send(RefCell::new(a));
let w = v.clone();
let b = v.borrow();
let mut b = b.borrow_mut();

View file

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::mutable::Mut;
use std::cell::RefCell;
fn main() {
let m = Mut::new(0);
let m = RefCell::new(0);
let mut b = m.borrow_mut();
let b1 = b.get();
let b2 = b.get(); //~ ERROR cannot borrow `b` as mutable more than once at a time

View file

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::mutable::Mut;
use std::cell::RefCell;
fn f<T: Freeze>(_: T) {}
fn main() {
let x = Mut::new(0);
let x = RefCell::new(0);
f(x); //~ ERROR: which does not fulfill `Freeze`
}

View file

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::mutable::Mut;
use std::cell::RefCell;
fn main() {
let m = Mut::new(0);
let m = RefCell::new(0);
let p;
{
let b = m.borrow();

View file

@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::mutable::Mut;
use std::cell::RefCell;
use std::rc::Rc;
fn o<T: Send>(_: &T) {}
fn c<T: Freeze>(_: &T) {}
fn main() {
let x = Rc::from_send(Mut::new(0));
o(&x); //~ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<std::mutable::Mut<int>>`, which does not fulfill `Send`
c(&x); //~ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<std::mutable::Mut<int>>`, which does not fulfill `Freeze`
let x = Rc::from_send(RefCell::new(0));
o(&x); //~ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Send`
c(&x); //~ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Freeze`
}