Skip to content

Commit b8c119a

Browse files
committed
Make all config keys optional
1 parent b9fcf15 commit b8c119a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/config.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use std::path::Path;
99
/// The main configuration.
1010
#[derive(Debug, Deserialize, Serialize, PartialEq)]
1111
pub struct Config {
12-
users: Vec<User>,
13-
organizations: Vec<Organization>,
14-
local: Vec<String>,
15-
sources: Vec<Source>,
12+
users: Option<Vec<User>>,
13+
organizations: Option<Vec<Organization>>,
14+
local: Option<Vec<String>>,
15+
sources: Option<Vec<Source>>,
1616
}
1717

1818
impl Config {
@@ -80,7 +80,7 @@ mod tests {
8080
url = "https://git.acme.corp"
8181
"#};
8282
let expected = Config {
83-
users: vec![
83+
users: Some(vec![
8484
User {
8585
name: "torvalds".to_string(),
8686
sources: vec!["github".to_string()],
@@ -105,21 +105,21 @@ mod tests {
105105
name: "pbrock".to_string(),
106106
sources: vec!["acme-corp".to_string()],
107107
},
108-
],
109-
organizations: vec![
108+
]),
109+
organizations: Some(vec![
110110
Organization {
111111
name: "rust-lang".to_string(),
112112
sources: vec!["github".to_string()],
113113
}
114-
],
115-
local: vec!["jdoe@example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHDGMF+tZQL3dcr1arPst+YP8v33Is0kAJVvyTKrxMw".parse().unwrap()],
116-
sources: vec![
114+
]),
115+
local: Some(vec!["jdoe@example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHDGMF+tZQL3dcr1arPst+YP8v33Is0kAJVvyTKrxMw".parse().unwrap()]),
116+
sources: Some(vec![
117117
Source {
118118
name: "acme-corp".to_string(),
119119
provider: GitProvider::Gitlab,
120120
url: "https://git.acme.corp".to_string(),
121121
}
122-
]
122+
])
123123
};
124124

125125
let config = Config::from_toml(toml).unwrap();

0 commit comments

Comments
 (0)