pub struct Style { /* private fields */ }
Expand description
Implementations§
§impl Style
impl Style
§Core
pub const fn fg_color(self, fg: Option<Color>) -> Style
pub const fn fg_color(self, fg: Option<Color>) -> Style
Set foreground color
§Examples
let style = anstyle::Style::new().fg_color(Some(anstyle::AnsiColor::Red.into()));
pub const fn bg_color(self, bg: Option<Color>) -> Style
pub const fn bg_color(self, bg: Option<Color>) -> Style
Set background color
§Examples
let style = anstyle::Style::new().bg_color(Some(anstyle::AnsiColor::Red.into()));
pub const fn underline_color(self, underline: Option<Color>) -> Style
pub const fn underline_color(self, underline: Option<Color>) -> Style
Set underline color
§Examples
let style = anstyle::Style::new().underline_color(Some(anstyle::AnsiColor::Red.into()));
pub const fn effects(self, effects: Effects) -> Style
pub const fn effects(self, effects: Effects) -> Style
Set text effects
§Examples
let style = anstyle::Style::new().effects(anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE);
pub fn render_reset(self) -> impl Display + Copy + Clone
pub fn render_reset(self) -> impl Display + Copy + Clone
Renders the relevant Reset
code
Unlike Reset::render
, this will elide the code if there is nothing to reset.
pub fn write_reset_to(self, write: &mut dyn Write) -> Result<(), Error>
pub fn write_reset_to(self, write: &mut dyn Write) -> Result<(), Error>
Write the relevant Reset
code
Unlike Reset::render
, this will elide the code if there is nothing to reset.
§impl Style
impl Style
§Convenience
§impl Style
impl Style
§Reflection
pub const fn get_fg_color(self) -> Option<Color>
pub const fn get_bg_color(self) -> Option<Color>
pub const fn get_underline_color(self) -> Option<Color>
pub const fn get_effects(self) -> Effects
Trait Implementations§
§impl BitOr<Effects> for Style
impl BitOr<Effects> for Style
§Examples
let style = anstyle::Style::new() | anstyle::Effects::BOLD.into();
§impl BitOrAssign<Effects> for Style
impl BitOrAssign<Effects> for Style
§Examples
let mut style = anstyle::Style::new();
style |= anstyle::Effects::BOLD.into();
§fn bitor_assign(&mut self, other: Effects)
fn bitor_assign(&mut self, other: Effects)
Performs the
|=
operation. Read more§impl Ord for Style
impl Ord for Style
§impl PartialEq<Effects> for Style
impl PartialEq<Effects> for Style
§Examples
let effects = anstyle::Effects::BOLD;
assert_eq!(anstyle::Style::new().effects(effects), effects);
assert_ne!(anstyle::Effects::UNDERLINE | effects, effects);
assert_ne!(anstyle::RgbColor(0, 0, 0).on_default() | effects, effects);
§impl PartialOrd for Style
impl PartialOrd for Style
§fn partial_cmp(&self, other: &Style) -> Option<Ordering>
fn partial_cmp(&self, other: &Style) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more§impl Sub<Effects> for Style
impl Sub<Effects> for Style
§Examples
let style = anstyle::Style::new().bold().underline() - anstyle::Effects::BOLD.into();
§impl SubAssign<Effects> for Style
impl SubAssign<Effects> for Style
§Examples
let mut style = anstyle::Style::new().bold().underline();
style -= anstyle::Effects::BOLD.into();
§fn sub_assign(&mut self, other: Effects)
fn sub_assign(&mut self, other: Effects)
Performs the
-=
operation. Read moreimpl Copy for Style
impl Eq for Style
impl StructuralEq for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
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
§impl<T> Clamp for Twhere
T: PartialOrd,
impl<T> Clamp for Twhere
T: PartialOrd,
§fn clamp_range(self, range: impl FixedRangeBounds<Self>) -> Selfwhere
Self: Clone,
fn clamp_range(self, range: impl FixedRangeBounds<Self>) -> Selfwhere
Self: Clone,
Clamps a value in range. Read more
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.