From 115fe07e2c11aa72e91a5ce9b028ed1c1ff7d806 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 2 Feb 2017 12:03:55 -0800 Subject: Add support for Table/Array and deep merging of configuration values --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 8af61c3..5f8957a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,11 +65,11 @@ pub use value::Value; pub use config::Config; // Global configuration -static mut CONFIG: Option>> = None; +static mut CONFIG: Option> = None; static CONFIG_INIT: Once = ONCE_INIT; // Get the global configuration instance -pub fn global() -> &'static mut RwLock> { +pub fn global() -> &'static mut RwLock { unsafe { CONFIG_INIT.call_once(|| { CONFIG = Some(Default::default()); @@ -86,18 +86,18 @@ pub fn merge(source: T) -> Result<(), Box> } pub fn set_default(key: &str, value: T) -> Result<(), Box> - where T: Into> + where T: Into { global().write().unwrap().set_default(key, value) } pub fn set(key: &str, value: T) -> Result<(), Box> - where T: Into> + where T: Into { global().write().unwrap().set(key, value) } -pub fn get<'a>(key: &str) -> Option> { +pub fn get<'a>(key: &str) -> Option<&'a Value> { // TODO(~): Should this panic! or return None with an error message? // Make an issue if you think it should be an error message. let r = global().read().unwrap(); -- cgit v1.2.3