1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-27 15:40:03 +08:00

add util_env

This commit is contained in:
2019-08-15 07:12:51 +08:00
parent 29e719477f
commit b15ea1aa7b
2 changed files with 10 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ use std::{
pub mod util_io;
pub mod util_os;
pub mod util_env;
pub mod util_cmd;
pub mod util_msg;
pub mod util_size;

9
src/util_env.rs Normal file
View File

@@ -0,0 +1,9 @@
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"),
}
}