Struct StyledStr

pub struct StyledStr(/* private field */);

Terminal-styling container

Styling may be encoded as ANSI Escape Code

Examples

# use clap_builder as clap;
// `cstr!` converts tags to ANSI codes
let after_help: &'static str = color_print::cstr!(
r#"<bold><underline>Examples</underline></bold>

  <dim>$</dim> <bold>mybin --input file.toml</bold>
"#);

let cmd = clap::Command::new("mybin")
    .after_help(after_help)  // The `&str` gets converted into a `StyledStr`
    // ...
#   ;

Implementations

impl StyledStr

const fn new() -> Self

Create an empty buffer

fn ansi(&self) -> impl Display + '_

Display using ANSI Escape Code styling

fn push_str(&mut self, msg: &str)

Appends a given string slice onto the end of this StyledStr.

Trait Implementations

impl Clone for StyledStr

fn clone(&self) -> StyledStr

impl Debug for StyledStr

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Default for StyledStr

fn default() -> StyledStr

impl Display for StyledStr

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Eq for StyledStr

impl From<&&'static str> for StyledStr

fn from(name: &&'static str) -> Self

impl From<&'static str> for StyledStr

fn from(name: &'static str) -> Self

impl From<&String> for StyledStr

fn from(name: &String) -> Self

impl From<Cow<'static, str>> for StyledStr

fn from(cow: Cow<'static, str>) -> Self

impl From<String> for StyledStr

fn from(name: String) -> Self

impl Ord for StyledStr

fn cmp(&self, other: &StyledStr) -> Ordering

impl PartialEq for StyledStr

fn eq(&self, other: &StyledStr) -> bool

impl PartialOrd for StyledStr

fn partial_cmp(&self, other: &StyledStr) -> Option<Ordering>

impl StructuralPartialEq for StyledStr

impl Write for StyledStr

fn write_str(&mut self, s: &str) -> Result<(), Error>
fn write_char(&mut self, c: char) -> Result<(), Error>

Auto Trait Implementations

impl Freeze for StyledStr

impl RefUnwindSafe for StyledStr

impl Send for StyledStr

impl Sync for StyledStr

impl Unpin for StyledStr

impl UnsafeUnpin for StyledStr

impl UnwindSafe for StyledStr

Blanket Implementations

impl<I> IntoResettable<StyledStr> for StyledStr where I: Into<StyledStr>,

fn into_resettable(self) -> Resettable<StyledStr>

impl<T> Any for StyledStr where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for StyledStr where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for StyledStr where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for StyledStr where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for StyledStr

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for StyledStr where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for StyledStr where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for StyledStr where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for StyledStr where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for StyledStr where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>