Skip to content

Commit 1eff7b3

Browse files
committed
global example: Use Config::builder() for building global settings
Signed-off-by: Matthias Beyer <[email protected]>
1 parent c8c50e5 commit 1eff7b3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/global/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ use std::error::Error;
88
use std::sync::RwLock;
99

1010
lazy_static! {
11-
static ref SETTINGS: RwLock<Config> = RwLock::new(Config::default());
11+
static ref SETTINGS: RwLock<Config> = RwLock::new({
12+
Config::builder()
13+
.set_default("property", 42).unwrap()
14+
.build().unwrap()
15+
});
1216
}
1317

1418
fn try_main() -> Result<(), Box<dyn Error>> {
15-
// Set property
16-
SETTINGS.write()?.set("property", 42)?;
17-
1819
// Get property
1920
println!("property: {}", SETTINGS.read()?.get::<i32>("property")?);
2021

0 commit comments

Comments
 (0)