File: dynamic_colors.rs

package info (click to toggle)
rust-colored 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 468 kB
  • sloc: makefile: 2
file content (14 lines) | stat: -rw-r--r-- 351 bytes parent folder | download | duplicates (28)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
extern crate colored;
use colored::*;

fn main() {
    // the easy way
    "blue string yo".color("blue");

    // this will default to white
    "white string".color("zorglub");

    // the safer way via a Result
    let color_res = "zorglub".parse(); // <- this returns a Result<Color, ()>
    "red string".color(color_res.unwrap_or(Color::Red));
}