-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimple.rs
43 lines (42 loc) · 908 Bytes
/
simple.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
extern crate no_color;
use no_color::*;
/// # Examples
///
/// ## testing environment variable `NO_COLOR` set
///
/// ```sh
/// export NO_COLOR; echo $NO_COLOR; cargo run --example simple
/// ```
///
/// ## testing environment variable `NO_COLOR` unset
///
/// ```sh
/// export NO_COLOR; echo $NO_COLOR; unset NO_COLOR; cargo run --example simple
/// ```
///
/// ## The following code is executed in the simple example
///
/// ```rust
/// println!(
/// "Environment variable NO_COLOR {0} found. Now do something.",
/// {
/// if is_no_color() {
/// "is"
/// } else {
/// "is NOT"
/// }
/// }
/// );
/// ```
fn main() {
println!(
"Environment variable NO_COLOR {0} found. Now do something.",
{
if is_no_color() {
"is"
} else {
"is NOT"
}
}
);
}