mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 23:40:05 +08:00
add read_str_to_lines, tests, fix bug
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
|
||||
use std::env;
|
||||
|
||||
pub fn is_env_on(var: &str) -> bool {
|
||||
env::var(var).map(|v| v.to_lowercase()).map(|v| vec!["true", "yes", "1"].iter().any(|x| x == &v)).unwrap_or(false)
|
||||
env::var(var).ok().map(|val| is_on(&val)).unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn is_on(val: &str) -> bool {
|
||||
let lower_val = val.to_lowercase();
|
||||
vec!["true", "yes", "1"].iter().any(|x| *x == lower_val)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user