pub struct Format<'a>(/* private fields */);Expand description
A collection of ANSI Attributes that can be applied to formatting or
textual elements.
This will disable itself if the environment variable NOCOLOR or NO_COLOR
is defined and set to some truthy value.
Implementations§
source§impl<'a> Format<'a>
impl<'a> Format<'a>
sourcepub const fn from_slice(attributes: &'a [Attribute]) -> Self
pub const fn from_slice(attributes: &'a [Attribute]) -> Self
sourcepub const fn wrap<'b>(
&'a self,
display: &'b dyn Display,
) -> FormatDisplay<'a, 'b>
pub const fn wrap<'b>( &'a self, display: &'b dyn Display, ) -> FormatDisplay<'a, 'b>
Wraps a formatted Display element into a FormatDisplay that
will automatically toggle the ANSI formatting before displaying the
element, and then follow it up with a fmt::RESET.
§Parameters
display- the element to display
sourcepub fn optimize_for<W>(self, writer: &W) -> Selfwhere
W: Write + IsTerminal,
pub fn optimize_for<W>(self, writer: &W) -> Selfwhere
W: Write + IsTerminal,
Computes and returns the optimal format for the specified writer
This will disable formatting if the writer does not support ANSI
formatting (determined by checking IsTerminal)
§Parameters
writer- the writer to write to
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Format<'a>
impl<'a> RefUnwindSafe for Format<'a>
impl<'a> Send for Format<'a>
impl<'a> Sync for Format<'a>
impl<'a> Unpin for Format<'a>
impl<'a> UnwindSafe for Format<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more