]> git.proxmox.com Git - rustc.git/blob - vendor/colored/examples/dynamic_colors.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / vendor / colored / examples / dynamic_colors.rs
1 extern crate colored;
2 use colored::*;
3
4 fn main() {
5 // the easy way
6 "blue string yo".color("blue");
7
8 // this will default to white
9 "white string".color("zorglub");
10
11 // the safer way via a Result
12 let color_res = "zorglub".parse(); // <- this returns a Result<Color, ()>
13 "red string".color(color_res.unwrap_or(Color::Red));
14 }