Skip to content

Commit cfdd11d

Browse files
committed
cargo fmt --all
1 parent 2b93478 commit cfdd11d

File tree

5 files changed

+70
-41
lines changed

5 files changed

+70
-41
lines changed

examples/glob/main.rs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use std::path::Path;
2-
use std::collections::HashMap;
31
use config::*;
42
use glob::glob;
3+
use std::collections::HashMap;
4+
use std::path::Path;
55

66
fn main() {
77
// Option 1
@@ -10,40 +10,59 @@ fn main() {
1010
let mut settings = Config::default();
1111
settings
1212
// File::with_name(..) is shorthand for File::from(Path::new(..))
13-
.merge(File::with_name("examples/glob/conf/00-default.toml")).unwrap()
14-
.merge(File::from(Path::new("examples/glob/conf/05-some.yml"))).unwrap()
15-
.merge(File::from(Path::new("examples/glob/conf/99-extra.json"))).unwrap();
13+
.merge(File::with_name("examples/glob/conf/00-default.toml"))
14+
.unwrap()
15+
.merge(File::from(Path::new("examples/glob/conf/05-some.yml")))
16+
.unwrap()
17+
.merge(File::from(Path::new("examples/glob/conf/99-extra.json")))
18+
.unwrap();
1619

1720
// Print out our settings (as a HashMap)
18-
println!("\n{:?} \n\n-----------",
19-
settings.try_deserialize::<HashMap<String, String>>().unwrap());
21+
println!(
22+
"\n{:?} \n\n-----------",
23+
settings
24+
.try_deserialize::<HashMap<String, String>>()
25+
.unwrap()
26+
);
2027

2128
// Option 2
2229
// --------
2330
// Gather all conf files from conf/ manually, but put in 1 merge call.
2431
let mut settings = Config::default();
2532
settings
26-
.merge(vec![File::with_name("examples/glob/conf/00-default.toml"),
27-
File::from(Path::new("examples/glob/conf/05-some.yml")),
28-
File::from(Path::new("examples/glob/conf/99-extra.json"))])
33+
.merge(vec![
34+
File::with_name("examples/glob/conf/00-default.toml"),
35+
File::from(Path::new("examples/glob/conf/05-some.yml")),
36+
File::from(Path::new("examples/glob/conf/99-extra.json")),
37+
])
2938
.unwrap();
3039

3140
// Print out our settings (as a HashMap)
32-
println!("\n{:?} \n\n-----------",
33-
settings.try_deserialize::<HashMap<String, String>>().unwrap());
41+
println!(
42+
"\n{:?} \n\n-----------",
43+
settings
44+
.try_deserialize::<HashMap<String, String>>()
45+
.unwrap()
46+
);
3447

3548
// Option 3
3649
// --------
3750
// Gather all conf files from conf/ using glob and put in 1 merge call.
3851
let mut settings = Config::default();
3952
settings
40-
.merge(glob("examples/glob/conf/*")
41-
.unwrap()
42-
.map(|path| File::from(path.unwrap()))
43-
.collect::<Vec<_>>())
53+
.merge(
54+
glob("examples/glob/conf/*")
55+
.unwrap()
56+
.map(|path| File::from(path.unwrap()))
57+
.collect::<Vec<_>>(),
58+
)
4459
.unwrap();
4560

4661
// Print out our settings (as a HashMap)
47-
println!("\n{:?} \n\n-----------",
48-
settings.try_deserialize::<HashMap<String, String>>().unwrap());
62+
println!(
63+
"\n{:?} \n\n-----------",
64+
settings
65+
.try_deserialize::<HashMap<String, String>>()
66+
.unwrap()
67+
);
4968
}

examples/global/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ extern crate lazy_static;
33

44
extern crate config;
55

6+
use config::Config;
67
use std::error::Error;
78
use std::sync::RwLock;
8-
use config::Config;
99

1010
lazy_static! {
11-
static ref SETTINGS: RwLock<Config> = RwLock::new(Config::default());
11+
static ref SETTINGS: RwLock<Config> = RwLock::new(Config::default());
1212
}
1313

1414
fn try_main() -> Result<(), Box<dyn Error>> {
15-
// Set property
16-
SETTINGS.write()?.set("property", 42)?;
15+
// Set property
16+
SETTINGS.write()?.set("property", 42)?;
1717

18-
// Get property
19-
println!("property: {}", SETTINGS.read()?.get::<i32>("property")?);
18+
// Get property
19+
println!("property: {}", SETTINGS.read()?.get::<i32>("property")?);
2020

21-
Ok(())
21+
Ok(())
2222
}
2323

2424
fn main() {
25-
try_main().unwrap()
25+
try_main().unwrap()
2626
}

examples/hierarchical-env/settings.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use config::{Config, ConfigError, Environment, File};
12
use std::env;
2-
use config::{ConfigError, Config, File, Environment};
33

44
#[derive(Debug, Deserialize)]
55
struct Database {
@@ -47,7 +47,9 @@ impl Settings {
4747
// Default to 'development' env
4848
// Note that this file is _optional_
4949
let env = env::var("RUN_MODE").unwrap_or_else(|_| "development".into());
50-
s.merge(File::with_name(&format!("examples/hierarchical-env/config/{}", env)).required(false))?;
50+
s.merge(
51+
File::with_name(&format!("examples/hierarchical-env/config/{}", env)).required(false),
52+
)?;
5153

5254
// Add in a local configuration file
5355
// This file shouldn't be checked in to git

examples/simple/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ fn main() {
44
let mut settings = config::Config::default();
55
settings
66
// Add in `./Settings.toml`
7-
.merge(config::File::with_name("examples/simple/Settings")).unwrap()
7+
.merge(config::File::with_name("examples/simple/Settings"))
8+
.unwrap()
89
// Add in settings from the environment (with a prefix of APP)
910
// Eg.. `APP_DEBUG=1 ./target/app` would set the `debug` key
10-
.merge(config::Environment::with_prefix("APP")).unwrap();
11+
.merge(config::Environment::with_prefix("APP"))
12+
.unwrap();
1113

1214
// Print out our settings (as a HashMap)
13-
println!("{:?}",
14-
settings.try_deserialize::<HashMap<String, String>>().unwrap());
15+
println!(
16+
"{:?}",
17+
settings
18+
.try_deserialize::<HashMap<String, String>>()
19+
.unwrap()
20+
);
1521
}

examples/watch/main.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use config::*;
2+
use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
23
use std::collections::HashMap;
3-
use std::sync::RwLock;
4-
use notify::{RecommendedWatcher, DebouncedEvent, Watcher, RecursiveMode};
54
use std::sync::mpsc::channel;
5+
use std::sync::RwLock;
66
use std::time::Duration;
77

88
lazy_static::lazy_static! {
@@ -15,13 +15,15 @@ lazy_static::lazy_static! {
1515
}
1616

1717
fn show() {
18-
println!(" * Settings :: \n\x1b[31m{:?}\x1b[0m",
19-
SETTINGS
20-
.read()
21-
.unwrap()
22-
.clone()
23-
.try_deserialize::<HashMap<String, String>>()
24-
.unwrap());
18+
println!(
19+
" * Settings :: \n\x1b[31m{:?}\x1b[0m",
20+
SETTINGS
21+
.read()
22+
.unwrap()
23+
.clone()
24+
.try_deserialize::<HashMap<String, String>>()
25+
.unwrap()
26+
);
2527
}
2628

2729
fn watch() {

0 commit comments

Comments
 (0)