2013-11-21 23:30:34 -06:00
|
|
|
use std::cell::RefCell;
|
2013-11-16 16:35:35 -06:00
|
|
|
|
2018-08-14 18:16:05 -05:00
|
|
|
|
|
|
|
|
2013-11-16 16:35:35 -06:00
|
|
|
fn main() {
|
2015-01-31 10:23:42 -06:00
|
|
|
let m = RefCell::new(0);
|
2013-11-16 16:35:35 -06:00
|
|
|
let mut b = m.borrow_mut();
|
2014-03-21 00:06:51 -05:00
|
|
|
let b1 = &mut *b;
|
|
|
|
let b2 = &mut *b; //~ ERROR cannot borrow
|
2018-08-14 18:16:05 -05:00
|
|
|
b1.use_mut();
|
2013-11-16 16:35:35 -06:00
|
|
|
}
|
2018-08-14 18:16:05 -05:00
|
|
|
|
|
|
|
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
|
|
|
|
impl<T> Fake for T { }
|