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
2014-01-01 07:46:27 +08:00
use std::cell::Cell;
use std::fmt;
2015-02-18 07:24:34 +08:00
use std::thread;
struct Foo(Cell<isize>);
2015-01-28 21:34:18 +08: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);
2014-01-01 07:46:27 +08:00
f.set(1);
2014-01-31 03:56:51 +08:00
Ok(())
}
}
pub fn main() {
thread::spawn(move || {
2014-01-01 07:46:27 +08:00
let mut f = Foo(Cell::new(0));
println!("{:?}", f);
let Foo(ref mut f) = f;
assert_eq!(f.get(), 1);
})
.join()
.ok()
.unwrap();
}