2019-07-26 21:54:25 +00:00
|
|
|
// run-pass
|
2014-08-11 23:24:19 +00:00
|
|
|
// ignore-windows
|
2016-02-11 11:34:41 +00:00
|
|
|
// ignore-emscripten no threads support
|
2019-04-30 08:27:53 +00:00
|
|
|
// exec-env:RUSTC_LOG=debug
|
2013-11-29 07:44:33 +00:00
|
|
|
|
2013-12-31 23:46:27 +00:00
|
|
|
use std::cell::Cell;
|
2013-11-29 07:44:33 +00:00
|
|
|
use std::fmt;
|
2015-02-17 23:24:34 +00:00
|
|
|
use std::thread;
|
2013-11-29 07:44:33 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
struct Foo(Cell<isize>);
|
2013-11-29 07:44:33 +00:00
|
|
|
|
2015-01-28 13:34:18 +00:00
|
|
|
impl fmt::Debug for Foo {
|
2014-02-05 12:55:13 +00:00
|
|
|
fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
let Foo(ref f) = *self;
|
2015-06-07 18:00:38 +00:00
|
|
|
assert_eq!(f.get(), 0);
|
2013-12-31 23:46:27 +00:00
|
|
|
f.set(1);
|
2014-01-30 19:56:51 +00:00
|
|
|
Ok(())
|
2013-11-29 07:44:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
2015-02-17 23:24:34 +00:00
|
|
|
thread::spawn(move|| {
|
2013-12-31 23:46:27 +00:00
|
|
|
let mut f = Foo(Cell::new(0));
|
2014-12-20 08:09:35 +00:00
|
|
|
println!("{:?}", f);
|
2013-11-02 01:06:31 +00:00
|
|
|
let Foo(ref mut f) = f;
|
2015-06-07 18:00:38 +00:00
|
|
|
assert_eq!(f.get(), 1);
|
2014-12-22 17:04:23 +00:00
|
|
|
}).join().ok().unwrap();
|
2013-11-29 07:44:33 +00:00
|
|
|
}
|