Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/dynamic_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use colored::{Color, Colorize};

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

// this will default to white
"white string".color("zorglub");
let _ = "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));
let _ = "red string".color(color_res.unwrap_or(Color::Red));
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pub use style::{Style, Styles};
/// Notice how this process preserves the coloring and style.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
#[must_use]
pub struct ColoredString {
/// The plain text that will have color and style applied to it.
pub input: String,
Expand Down