2013-06-17 19:25:06 -04:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
// Testing guarantees provided by once functions.
|
|
|
|
|
2013-06-29 03:54:09 -04:00
|
|
|
// xfail-fast
|
|
|
|
|
2013-10-15 07:21:54 +02:00
|
|
|
#[feature(once_fns)];
|
2014-01-30 15:04:47 -05:00
|
|
|
extern mod sync;
|
|
|
|
use sync::Arc;
|
2013-06-17 19:25:06 -04:00
|
|
|
|
2013-11-19 18:15:10 -08:00
|
|
|
fn foo(blk: once ||) {
|
2013-06-17 19:25:06 -04:00
|
|
|
blk();
|
|
|
|
}
|
|
|
|
|
2014-01-03 15:30:54 -08:00
|
|
|
pub fn main() {
|
2014-01-30 15:04:47 -05:00
|
|
|
let x = Arc::new(true);
|
2013-11-21 17:23:21 -08:00
|
|
|
foo(|| {
|
2013-06-17 19:25:06 -04:00
|
|
|
assert!(*x.get());
|
2013-12-02 22:37:26 -08:00
|
|
|
drop(x);
|
2013-11-21 17:23:21 -08:00
|
|
|
})
|
2013-06-17 19:25:06 -04:00
|
|
|
}
|