Skip to content

Commit 98b7804

Browse files
joelgallantjohnb8
authored andcommitted
Renames parse_numbers to try_parsing
1 parent a5c3fab commit 98b7804

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/env.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub struct Environment {
2525
/// Ignore empty env values (treat as unset).
2626
ignore_empty: bool,
2727

28-
/// Parse numbers if they're detected.
29-
parse_numbers: bool,
28+
/// Parses booleans, integers and floats if they're detected (can be safely parsed).
29+
try_parsing: bool,
3030
}
3131

3232
impl Environment {
@@ -56,8 +56,8 @@ impl Environment {
5656
self
5757
}
5858

59-
pub fn parse_numbers(mut self, parse_numbers: bool) -> Self {
60-
self.parse_numbers = parse_numbers;
59+
pub fn try_parsing(mut self, try_parsing: bool) -> Self {
60+
self.try_parsing = try_parsing;
6161
self
6262
}
6363
}
@@ -68,7 +68,7 @@ impl Default for Environment {
6868
prefix: None,
6969
separator: None,
7070
ignore_empty: false,
71-
parse_numbers: false,
71+
try_parsing: false,
7272
}
7373
}
7474
}
@@ -125,7 +125,7 @@ impl Source for Environment {
125125
key = key.replace(separator, ".");
126126
}
127127

128-
let value = if self.parse_numbers {
128+
let value = if self.try_parsing {
129129
let string_value = Value::new(Some(&uri), ValueKind::String(value.clone()));
130130

131131
if let Ok(parsed) = string_value.clone().into_int() {

tests/env.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ fn test_parse_numbers() {
8989
env::set_var("FLOAT_VAL", "42.2");
9090
env::set_var("BOOL_VAL", "true");
9191

92-
let environment = Environment::new().parse_numbers(true);
92+
let environment = Environment::new().try_parsing(true);
93+
9394
let values = environment.collect().unwrap();
9495

9596
assert_eq!(

0 commit comments

Comments
 (0)