Skip to content

Commit

Permalink
refactor(env): Clean up initialization code
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 7, 2025
1 parent 2ee2c63 commit 2142beb
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,8 @@ impl Environment {
/// Once `list_separator` is set, the type for string is [`Vec<String>`].
/// To switch the default type back to type Strings you need to provide the keys which should be [`Vec<String>`] using this function.
pub fn with_list_parse_key(mut self, key: &str) -> Self {
if self.list_parse_keys.is_none() {
self.list_parse_keys = Some(vec![key.into()]);
} else {
self.list_parse_keys = self.list_parse_keys.map(|mut keys| {
keys.push(key.into());
keys
});
}
let keys = self.list_parse_keys.get_or_insert_with(Vec::new);
keys.push(key.into());
self
}

Expand Down

0 comments on commit 2142beb

Please sign in to comment.