1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-29 00:20:04 +08:00
This commit is contained in:
2020-04-12 00:55:37 +08:00
parent b8da734669
commit 7811e29921
3 changed files with 11 additions and 21 deletions

View File

@@ -2,8 +2,5 @@
use std::env;
pub fn is_env_on(var: &str) -> bool {
match env::var(var) {
Err(_) => false,
Ok(v) => (v == "TRUE" || v == "true" || v =="YES" || v == "yes" || v == "1"),
}
env::var(var).map(|v| v.to_lowercase()).map(|v| (v == "true" || v == "yes" || v == "1")).unwrap_or(false)
}