Skip to content

Commit 2142beb

Browse files
committed
refactor(env): Clean up initialization code
1 parent 2ee2c63 commit 2142beb

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/env.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,8 @@ impl Environment {
151151
/// Once `list_separator` is set, the type for string is [`Vec<String>`].
152152
/// To switch the default type back to type Strings you need to provide the keys which should be [`Vec<String>`] using this function.
153153
pub fn with_list_parse_key(mut self, key: &str) -> Self {
154-
if self.list_parse_keys.is_none() {
155-
self.list_parse_keys = Some(vec![key.into()]);
156-
} else {
157-
self.list_parse_keys = self.list_parse_keys.map(|mut keys| {
158-
keys.push(key.into());
159-
keys
160-
});
161-
}
154+
let keys = self.list_parse_keys.get_or_insert_with(Vec::new);
155+
keys.push(key.into());
162156
self
163157
}
164158

0 commit comments

Comments
 (0)