Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Context {
- t: Option<i32>,
- }
- impl Context {
- fn new() -> Context {
- Context {t:None}
- }
- fn init(&mut self) {
- self.t = Some(12);
- }
- }
- thread_local! {
- static CONTEXT: Context = Context::new();
- }
- fn main() {
- CONTEXT.with(|c| {
- c.init();
- });
- CONTEXT.with(|c| println!("{}", c.t.unwrap()));
- }
Add Comment
Please, Sign In to add comment