1
0
mirror of https://github.com/jht5945/rust_util.git synced 2026-03-12 10:10:04 +08:00

Compare commits

...

2 Commits

Author SHA1 Message Date
d75c331fa0 ref use 2020-04-12 19:46:12 +08:00
34df5b66a2 ref is_env_on 2020-04-12 18:19:34 +08:00
2 changed files with 2 additions and 4 deletions

View File

@@ -2,9 +2,7 @@
extern crate lazy_static; extern crate lazy_static;
extern crate term; extern crate term;
use std::{ use std::io::{ Error, ErrorKind, };
io::{Error, ErrorKind},
};
pub mod util_io; pub mod util_io;
pub mod util_os; pub mod util_os;

View File

@@ -2,5 +2,5 @@
use std::env; use std::env;
pub fn is_env_on(var: &str) -> bool { 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)
} }