rust/tests/ui/logging-only-prints-once.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
566 B
Rust
Raw Normal View History

// run-pass
// ignore-windows
// ignore-emscripten no threads support
2013-12-31 17:46:27 -06:00
use std::cell::Cell;
use std::fmt;
2015-02-17 17:24:34 -06:00
use std::thread;
struct Foo(Cell<isize>);
2015-01-28 07:34:18 -06:00
impl fmt::Debug for Foo {
fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result {
let Foo(ref f) = *self;
assert_eq!(f.get(), 0);
2013-12-31 17:46:27 -06:00
f.set(1);
2014-01-30 13:56:51 -06:00
Ok(())
}
}
pub fn main() {
thread::spawn(move || {
2013-12-31 17:46:27 -06:00
let mut f = Foo(Cell::new(0));
println!("{:?}", f);
let Foo(ref mut f) = f;
assert_eq!(f.get(), 1);
})
.join()
.ok()
.unwrap();
}