summaryrefslogtreecommitdiffstats
path: root/vendor/colored/examples/dynamic_colors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/colored/examples/dynamic_colors.rs')
-rwxr-xr-xvendor/colored/examples/dynamic_colors.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/vendor/colored/examples/dynamic_colors.rs b/vendor/colored/examples/dynamic_colors.rs
new file mode 100755
index 000000000..d9861f425
--- /dev/null
+++ b/vendor/colored/examples/dynamic_colors.rs
@@ -0,0 +1,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));
+}