-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set default isolation settings to env maximums
- Loading branch information
1 parent
1ebbda5
commit 03dd63e
Showing
5 changed files
with
39 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod parsed_env; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::env; | ||
|
||
pub fn get<S>(name: S, default: u64) -> u64 | ||
where | ||
S: Into<String>, | ||
{ | ||
let name_string = name.into(); | ||
|
||
match env::var(name_string.clone()) { | ||
Ok(value) => match value.as_str() { | ||
"-1" => default, | ||
_ => match value.parse() { | ||
Ok(max) => max, | ||
Err(e) => { | ||
eprintln!( | ||
"Failed to parse environment variable '{}' as an `u64`: {}", | ||
name_string, e | ||
); | ||
|
||
default | ||
} | ||
}, | ||
}, | ||
Err(_) => default, | ||
} | ||
} |