Skip to main content

Path

Struct Path 

pub struct Path { /* private fields */ }
Expand description

A borrowed reference to a subset of a path, e.g. another Path or a [PathBuf]

Implementations§

§

impl Path

Conversions

pub const MAX_COMPONENT_LENGTH: usize

Path components must be 255 bytes or less

pub const EMPTY: &'static Path

An empty path for use as a default value, placeholder, comparisons, etc.

pub const KERNEL_PATH: &'static str = "$kernel"

Base kernel path.

pub const ABSOLUTE_KERNEL_PATH: &'static str = "::$kernel"

pub const KERNEL: &'static Path

pub const EXEC_PATH: &'static str = "$exec"

Path for an executable module.

pub const ABSOLUTE_EXEC_PATH: &'static str = "::$exec"

pub const EXEC: &'static Path

pub fn new<S>(path: &S) -> &Path
where S: AsRef<str> + ?Sized,

pub fn from_mut(path: &mut str) -> &mut Path

pub fn validate(path: &str) -> Result<&Path, PathError>

Verify that path meets all the requirements for a valid Path

pub const fn kernel_path() -> &'static Path

Get a Path corresponding to Self::KERNEL_PATH

pub const fn exec_path() -> &'static Path

Get a Path corresponding to Self::EXEC_PATH

pub const fn as_str(&self) -> &str

pub fn as_mut_str(&mut self) -> &mut str

pub fn as_ident(&self) -> Option<Ident>

Get an [Ident] that is equivalent to this Path, so long as the path has only a single component.

Returns None if the path cannot be losslessly represented as a single component.

pub fn to_path_buf(&self) -> PathBuf

Convert this Path to an owned [PathBuf]

pub fn from_ident(ident: &Ident) -> Cow<'_, Path>

Convert an [Ident] to an equivalent Path or [PathBuf], depending on whether the identifier would require quoting as a path.

§

impl Path

Accesssors

pub fn is_empty(&self) -> bool

Returns true if this path is empty (i.e. has no components)

pub fn len(&self) -> usize

Returns the number of components in the path

pub fn char_len(&self) -> usize

Return the size of the path in chars when displayed as a string

pub fn byte_len(&self) -> usize

Return the size of the path in bytes when displayed as a string

pub fn is_absolute(&self) -> bool

Returns true if this path is an absolute path

pub fn to_absolute(&self) -> Cow<'_, Path>

Make this path absolute, if not already

NOTE: This does not resolve the path, it simply ensures the path has the root prefix

pub fn to_relative(&self) -> &Path

Strip the root prefix from this path, if it has one.

pub fn parent(&self) -> Option<&Path>

Returns the Path without its final component, if there is one.

This means it may return an empty Path for relative paths with a single component.

Returns None if the path terminates with the root prefix, or if it is empty.

pub fn components(&self) -> Iter<'_>

Returns an iterator over all components of the path.

pub fn first(&self) -> Option<&str>

Get the first non-root component of this path as a str

Returns None if the path is empty, or consists only of the root prefix.

pub fn last(&self) -> Option<&str>

Get the first non-root component of this path as a str

Returns None if the path is empty, or consists only of the root prefix.

pub fn split_first(&self) -> Option<(&str, &Path)>

Splits this path on the first non-root component, returning it and a new Path of the remaining components.

Returns None if there are no components to split

pub fn split_last(&self) -> Option<(&str, &Path)>

Splits this path on the last component, returning it and a new Path of the remaining components.

Returns None if there are no components to split

pub fn is_kernel_path(&self) -> bool

Returns true if this path is for the root kernel module.

pub fn is_in_kernel(&self) -> bool

Returns true if this path is for the root kernel module or an item in it

pub fn is_exec_path(&self) -> bool

Returns true if this path is for an executable module.

pub fn is_in_exec(&self) -> bool

Returns true if this path is for the executable module or an item in it

pub fn starts_with<Prefix>(&self, prefix: &Prefix) -> bool
where Path: StartsWith<Prefix>, Prefix: ?Sized,

Returns true if the current path, sans root component, starts with prefix

The matching semantics of Prefix depend on the implementation of [StartsWith<Prefix>], in particular, if Prefix is str, then the prefix is matched against the first non-root component of self, regardless of whether the string contains path delimiters (i.e. ::).

See the [StartsWith] trait for more details.

pub fn starts_with_exactly<Prefix>(&self, prefix: &Prefix) -> bool
where Path: StartsWith<Prefix>, Prefix: ?Sized,

Returns true if the current path, including root component, starts with prefix

The matching semantics of Prefix depend on the implementation of [StartsWith<Prefix>], in particular, if Prefix is str, then the prefix is matched against the first component of self, regardless of whether the string contains path delimiters (i.e. ::).

See the [StartsWith] trait for more details.

pub fn strip_prefix<'a>(&'a self, prefix: &Path) -> Option<&'a Path>

Strips prefix from self, or returns None if self does not start with prefix.

NOTE: Prefixes must be exact, i.e. if you call path.strip_prefix(prefix) and path is relative but prefix is absolute, then this will return None. The same is true if path is absolute and prefix is relative.

pub fn join<P>(&self, other: &P) -> PathBuf
where Path: Join<P>, P: ?Sized,

Create an owned [PathBuf] with path adjoined to self.

If path is absolute, it replaces the current path.

The semantics of how other is joined to self in the resulting path depends on the implementation of [Join] used. The implementation for Path and [PathBuf] joins all components of other to self; while the implementation for [prim@str], string-like values, and identifiers/symbols joins just a single component. You must be careful to ensure that if you are passing a string here, that you specifically want to join it as a single component, or the resulting path may be different than you expect. It is recommended that you use Path::new(&string)` if you want to be explicit about treating a string-like value as a multi-component path.

pub fn canonicalize(&self) -> Result<PathBuf, PathError>

Canonicalize this path by ensuring that all components are in canonical form.

Canonical form dictates that:

  • A component is quoted only if it requires quoting, and unquoted otherwise
  • Is made absolute if relative and the first component is $kernel or $exec

Returns Err if the path is invalid

Trait Implementations§

§

impl AsRef<Path> for Path

§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
§

impl AsRef<Path> for str

§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
§

impl AsRef<str> for Path

§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
§

impl Debug for Path

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for &'de Path

Available on crate feature serde only.
§

fn deserialize<D>( deserializer: D, ) -> Result<&'de Path, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for Path

§

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

Formats the value using the given formatter. Read more
§

impl Hash for Path

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
§

impl Join<Arc<str>> for Path

§

fn join(&self, other: &Arc<str>) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Join<Box<str>> for Path

§

fn join(&self, other: &Box<str>) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Join<Ident> for Path

§

fn join(&self, other: &Ident) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Join<Path> for Path

§

fn join(&self, other: &Path) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Join<PathBuf> for Path

§

fn join(&self, other: &PathBuf) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Join<ProcedureName> for Path

§

fn join(&self, other: &ProcedureName) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Join<QualifiedProcedureName> for Path

§

fn join(&self, other: &QualifiedProcedureName) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Join<String> for Path

§

fn join(&self, other: &String) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Join<str> for Path

§

fn join(&self, other: &str) -> PathBuf

Joins other to self, producing a new [PathBuf] containing the joined path. Read more
§

impl Ord for Path

§

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

This method returns an Ordering between self and other. Read more
§

impl PartialEq<&Path> for Path

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq<&PathBuf> for Path

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq<Arc<Path>> for Path

§

fn eq(&self, other: &Arc<Path>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq<Box<Path>> for Path

§

fn eq(&self, other: &Box<Path>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq<Cow<'_, Path>> for Path

§

fn eq(&self, other: &Cow<'_, Path>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq<PathBuf> for Path

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq<Rc<Path>> for Path

§

fn eq(&self, other: &Rc<Path>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq<str> for Path

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq for Path

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd for Path

§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Serializable for Path

§

fn write_into<W>(&self, target: &mut W)
where W: ByteWriter,

Serializes self into bytes and writes these bytes into the target.
§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
§

impl Serialize for Path

Available on crate feature serde only.
§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl StartsWith<Path> for Path

§

fn starts_with(&self, prefix: &Path) -> bool

Returns true if the current path, sans root component, starts with prefix
§

fn starts_with_exactly(&self, prefix: &Path) -> bool

Returns true if the current path, including root component, starts with prefix
§

impl StartsWith<str> for Path

§

fn starts_with(&self, prefix: &str) -> bool

Returns true if the current path, sans root component, starts with prefix
§

fn starts_with_exactly(&self, prefix: &str) -> bool

Returns true if the current path, including root component, starts with prefix
§

impl ToOwned for Path

§

type Owned = PathBuf

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> PathBuf

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut <Path as ToOwned>::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl Eq for Path

§

impl StructuralPartialEq for Path

Auto Trait Implementations§

§

impl Freeze for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl !Sized for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnsafeUnpin for Path

§

impl UnwindSafe for Path

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Paint for T
where T: ?Sized,

§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling [Attribute] value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi [Quirk] value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the [Condition] value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new [Painted] with a default [Style]. Read more
§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more