From 7050abcaa862e2b500badbd4688600bbd5d44ff4 Mon Sep 17 00:00:00 2001 From: Zaira Bibi Date: Fri, 1 Nov 2024 12:24:39 +0500 Subject: [PATCH] feat: Implemented From> for StyledStr --- clap_builder/src/builder/styled_str.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/clap_builder/src/builder/styled_str.rs b/clap_builder/src/builder/styled_str.rs index 2b08bf42bea..c8d2c92203d 100644 --- a/clap_builder/src/builder/styled_str.rs +++ b/clap_builder/src/builder/styled_str.rs @@ -1,5 +1,7 @@ #![cfg_attr(not(feature = "usage"), allow(dead_code))] +use std::borrow::Cow; + /// Terminal-styling container /// /// Styling may be encoded as [ANSI Escape Code](https://en.wikipedia.org/wiki/ANSI_escape_code) @@ -208,3 +210,9 @@ impl std::fmt::Display for StyledStr { Ok(()) } } + +impl From> for StyledStr { + fn from(value: Cow<'static, str>) -> Self { + StyledStr(value.to_string()) + } +}