#[macro_export]
macro_rules! scoped_thread_local {
(static $name:ident: $t:ty) => (
- __scoped_thread_local_inner!(static $name: $t)
+ __scoped_thread_local_inner!(static $name: $t);
);
(pub static $name:ident: $t:ty) => (
- __scoped_thread_local_inner!(pub static $name: $t)
+ __scoped_thread_local_inner!(pub static $name: $t);
);
}
use cell::Cell;
use prelude::*;
+ scoped_thread_local!(static FOO: uint);
+
#[test]
fn smoke() {
scoped_thread_local!(static BAR: uint);
});
});
}
+
+ #[test]
+ fn scope_item_allowed() {
+ assert!(!FOO.is_set());
+ FOO.set(&1, || {
+ assert!(FOO.is_set());
+ FOO.with(|slot| {
+ assert_eq!(*slot, 1);
+ });
+ });
+ assert!(!FOO.is_set());
+ }
}