Skip to content

Instantly share code, notes, and snippets.

@panicbit
Created November 26, 2015 20:37
Show Gist options
  • Save panicbit/105770f68848907de07f to your computer and use it in GitHub Desktop.
Save panicbit/105770f68848907de07f to your computer and use it in GitHub Desktop.
use std::cell::RefCell;
thread_local!(static DIR: RefCell<String> = RefCell::new(String::new()));
fn main() {
DIR.with(|f| {
f.borrow_mut().push_str("foobar");
});
DIR.with(|f| {
println!("{}", *f.borrow());
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment