Skip to content

Instantly share code, notes, and snippets.

@pzol
Created March 4, 2014 18:03
Show Gist options
  • Save pzol/9352100 to your computer and use it in GitHub Desktop.
Save pzol/9352100 to your computer and use it in GitHub Desktop.
use std::local_data;
trait Locale {
fn to_upper(&self, s: &str) {}
}
struct Indifferent;
impl Locale for Indifferent {}
local_data_key!(key_current_locale: &'static Locale)
static indifferent: Indifferent = Indifferent;
fn current() -> &Locale {
local_data::get(key_current_locale, |_opt| &indifferent as &Locale)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment