summaryrefslogtreecommitdiffstats
path: root/examples/global/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/global/src/main.rs')
-rw-r--r--examples/global/src/main.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/global/src/main.rs b/examples/global/src/main.rs
new file mode 100644
index 0000000..4fe0864
--- /dev/null
+++ b/examples/global/src/main.rs
@@ -0,0 +1,26 @@
+#[macro_use]
+extern crate lazy_static;
+
+extern crate config;
+
+use std::error::Error;
+use std::sync::RwLock;
+use config::Config;
+
+lazy_static! {
+ static ref SETTINGS: RwLock<Config> = RwLock::new(Config::default());
+}
+
+fn try_main() -> Result<(), Box<Error>> {
+ // Set property
+ SETTINGS.write()?.set("property", 42)?;
+
+ // Get property
+ println!("property: {}", SETTINGS.read()?.get::<i32>("property")?);
+
+ Ok(())
+}
+
+fn main() {
+ try_main().unwrap()
+}