1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-27 07:30:05 +08:00

ref is_env_on

This commit is contained in:
2020-04-12 18:19:34 +08:00
parent d218e1edd5
commit 34df5b66a2

View File

@@ -2,5 +2,5 @@
use std::env;
pub fn is_env_on(var: &str) -> bool {
env::var(var).map(|v| v.to_lowercase()).map(|v| (v == "true" || v == "yes" || v == "1")).unwrap_or(false)
env::var(var).map(|v| v.to_lowercase()).map(|v| vec!["true", "yes", "1"].iter().any(|x| x == &v)).unwrap_or(false)
}