basic/
basic.rs

1#[macro_use]
2extern crate execution_context;
3
4use execution_context::ExecutionContext;
5use std::env;
6use std::thread;
7
8flow_local!(static LOCALE: String = env::var("LANG").unwrap_or_else(|_| "en_US".into()));
9
10fn main() {
11    println!("the current locale is {}", LOCALE.get());
12    LOCALE.set("de_DE".into());
13    println!("changing locale to {}", LOCALE.get());
14
15    let ec = ExecutionContext::capture();
16    thread::spawn(move || {
17        ec.run(|| {
18            println!("the locale in the child thread is {}", LOCALE.get());
19            LOCALE.set("fr_FR".into());
20            println!("the new locale in the child thread is {}", LOCALE.get());
21        });
22    }).join().unwrap();
23
24    println!("the locale of the parent thread is again {}", LOCALE.get());
25}