pub struct AstSnippet<'ast> {
pub builder: AstBuilder<'ast>,
}
Fields§
§builder: AstBuilder<'ast>
Implementations§
Source§impl<'ast> AstSnippet<'ast>
impl<'ast> AstSnippet<'ast>
pub fn new(alloc: &'ast Allocator) -> Self
pub fn alloc(&self) -> &'ast Allocator
pub fn atom(&self, value: &str) -> Atom<'ast>
pub fn id(&self, name: &'_ str, span: Span) -> BindingIdentifier<'ast>
pub fn alloc_id_ref( &self, name: &'_ str, span: Span, ) -> Box<'ast, IdentifierReference<'ast>>
pub fn id_name(&self, name: &'_ str, span: Span) -> IdentifierName<'ast>
pub fn id_ref_expr(&self, name: &'_ str, span: Span) -> Expression<'ast>
pub fn member_expr_or_ident_ref( &self, object: Expression<'ast>, names: &[CompactStr], span: Span, ) -> Expression<'ast>
Sourcepub fn member_expr_with_void_zero_object(
&self,
names: &[CompactStr],
span: Span,
) -> Expression<'ast>
pub fn member_expr_with_void_zero_object( &self, names: &[CompactStr], span: Span, ) -> Expression<'ast>
The props of foo_exports.value.a
is ["value", "a"]
, here convert it to (void 0).a
Sourcepub fn literal_prop_access_member_expr(
&self,
object: &'_ str,
property: &'_ str,
) -> MemberExpression<'ast>
pub fn literal_prop_access_member_expr( &self, object: &'_ str, property: &'_ str, ) -> MemberExpression<'ast>
[object].[property]
Sourcepub fn literal_prop_access_member_expr_expr(
&self,
object: &'_ str,
property: &'_ str,
) -> Expression<'ast>
pub fn literal_prop_access_member_expr_expr( &self, object: &'_ str, property: &'_ str, ) -> Expression<'ast>
[object].[property]
Sourcepub fn call_expr_expr(&self, name: &'_ str) -> Expression<'ast>
pub fn call_expr_expr(&self, name: &'_ str) -> Expression<'ast>
name()
Sourcepub fn call_expr_with_arg_expr(
&self,
name: Expression<'ast>,
arg: Expression<'ast>,
pure: bool,
) -> Expression<'ast>
pub fn call_expr_with_arg_expr( &self, name: Expression<'ast>, arg: Expression<'ast>, pure: bool, ) -> Expression<'ast>
name(arg)
Sourcepub fn call_expr_with_arg_expr_expr(
&self,
name: &'_ str,
arg: Expression<'ast>,
) -> Expression<'ast>
pub fn call_expr_with_arg_expr_expr( &self, name: &'_ str, arg: Expression<'ast>, ) -> Expression<'ast>
name(arg)
Sourcepub fn call_expr_with_2arg_expr(
&self,
name: Expression<'ast>,
arg1: Expression<'ast>,
arg2: Expression<'ast>,
) -> Expression<'ast>
pub fn call_expr_with_2arg_expr( &self, name: Expression<'ast>, arg1: Expression<'ast>, arg2: Expression<'ast>, ) -> Expression<'ast>
name(arg1, arg2)
Sourcepub fn alloc_call_expr_with_2arg_expr_expr(
&self,
name: &'_ str,
arg1: Expression<'ast>,
arg2: Expression<'ast>,
) -> Expression<'ast>
pub fn alloc_call_expr_with_2arg_expr_expr( &self, name: &'_ str, arg1: Expression<'ast>, arg2: Expression<'ast>, ) -> Expression<'ast>
name(arg1, arg2)
Sourcepub fn call_expr_with_2arg_expr_expr(
&self,
name: Expression<'ast>,
arg1: Expression<'ast>,
arg2: Expression<'ast>,
) -> Expression<'ast>
pub fn call_expr_with_2arg_expr_expr( &self, name: Expression<'ast>, arg1: Expression<'ast>, arg2: Expression<'ast>, ) -> Expression<'ast>
name(arg1, arg2)
Sourcepub fn call_expr_stmt(&self, name: &'_ str) -> Statement<'ast>
pub fn call_expr_stmt(&self, name: &'_ str) -> Statement<'ast>
name()
Sourcepub fn var_decl_stmt(
&self,
name: &'_ str,
init: Expression<'ast>,
) -> Statement<'ast>
pub fn var_decl_stmt( &self, name: &'_ str, init: Expression<'ast>, ) -> Statement<'ast>
var [name] = [init]
Sourcepub fn commonjs_wrapper_stmt(
&self,
binding_name: &'_ str,
commonjs_expr: Expression<'ast>,
statements: Vec<'ast, Statement<'ast>>,
ast_usage: EcmaModuleAstUsage,
profiler_names: bool,
stable_id: &str,
) -> Statement<'ast>
pub fn commonjs_wrapper_stmt( &self, binding_name: &'_ str, commonjs_expr: Expression<'ast>, statements: Vec<'ast, Statement<'ast>>, ast_usage: EcmaModuleAstUsage, profiler_names: bool, stable_id: &str, ) -> Statement<'ast>
var require_foo = __commonJS(((exports, module) => {
...
}));
or
__commonJSMin when `options.profiler_names` is false
Sourcepub fn esm_wrapper_stmt(
&self,
binding_name: &'_ str,
esm_fn_expr: Expression<'ast>,
statements: Vec<'ast, Statement<'ast>>,
profiler_names: bool,
use_pife: bool,
stable_id: &str,
is_async: bool,
) -> Statement<'ast>
pub fn esm_wrapper_stmt( &self, binding_name: &'_ str, esm_fn_expr: Expression<'ast>, statements: Vec<'ast, Statement<'ast>>, profiler_names: bool, use_pife: bool, stable_id: &str, is_async: bool, ) -> Statement<'ast>
var init_foo = __esm((() => { ... }));
Sourcepub fn seq2_in_paren_expr(
&self,
a: Expression<'ast>,
b: Expression<'ast>,
) -> Expression<'ast>
pub fn seq2_in_paren_expr( &self, a: Expression<'ast>, b: Expression<'ast>, ) -> Expression<'ast>
(a, b)
pub fn number_expr(&self, value: f64, raw: &'ast str) -> Expression<'ast>
Sourcepub fn simple_id_assignment_target(
&self,
id: &'_ str,
span: Span,
) -> AssignmentTarget<'ast>
pub fn simple_id_assignment_target( &self, id: &'_ str, span: Span, ) -> AssignmentTarget<'ast>
id = ...
 ̄ ̄ AssignmentTarget
Sourcepub fn only_return_arrow_expr(&self, expr: Expression<'ast>) -> Expression<'ast>
pub fn only_return_arrow_expr(&self, expr: Expression<'ast>) -> Expression<'ast>
() => xx
Sourcepub fn void_zero(&self) -> Expression<'ast>
pub fn void_zero(&self) -> Expression<'ast>
undefined
is acting like identifier, it might be shadowed by user code.
pub fn alloc_string_literal( &self, value: &'_ str, span: Span, ) -> Box<'ast, StringLiteral<'ast>>
pub fn string_literal_expr( &self, value: &'_ str, span: Span, ) -> Expression<'ast>
pub fn import_star_stmt( &self, source: &'_ str, as_name: &'_ str, ) -> Statement<'ast>
Sourcepub fn variable_declarator_require_call_stmt(
&self,
assignee: &str,
init: Expression<'ast>,
span: Span,
) -> Statement<'ast>
pub fn variable_declarator_require_call_stmt( &self, assignee: &str, init: Expression<'ast>, span: Span, ) -> Statement<'ast>
var [assignee] = require([source]);
Sourcepub fn promise_resolve_then_call_expr(
&self,
expr: Expression<'ast>,
) -> Expression<'ast>
pub fn promise_resolve_then_call_expr( &self, expr: Expression<'ast>, ) -> Expression<'ast>
Promise.resolve().then(() => expr))
pub fn callee_then_call_expr( &self, call_expr: Expression<'ast>, return_expr: Expression<'ast>, ) -> Expression<'ast>
pub fn object_property_kind_object_property( &self, key: &'_ str, expr: Expression<'ast>, computed: bool, ) -> ObjectPropertyKind<'ast>
pub fn to_esm_call_with_interop( &self, to_esm_fn_name: &'_ str, call_expr: Expression<'ast>, interop: Option<Interop>, ) -> Expression<'ast>
pub fn wrap_with_to_esm( &self, to_esm_fn_expr: Expression<'ast>, expr: Expression<'ast>, node_mode: bool, ) -> Expression<'ast>
Sourcepub fn export_default_expr_stmt(
&self,
expr: Expression<'ast>,
) -> Statement<'ast>
pub fn export_default_expr_stmt( &self, expr: Expression<'ast>, ) -> Statement<'ast>
convert Expression
to
export default ${Expression}
Sourcepub fn module_exports_expr_stmt(
&self,
expr: Expression<'ast>,
) -> Statement<'ast>
pub fn module_exports_expr_stmt( &self, expr: Expression<'ast>, ) -> Statement<'ast>
convert Expression
to
module.exports = ${Expression}
pub fn expr_without_parentheses( &self, expr: Expression<'ast>, ) -> Expression<'ast>
pub fn statement_module_declaration_export_named_declaration<T: AsRef<str>>( &self, declaration: Option<Declaration<'ast>>, specifiers: &[(T, T, bool)], ) -> Statement<'ast>
pub fn keep_name_call_expr( &self, original_name: &'_ str, target: Expression<'ast>, callee: Expression<'ast>, pure: bool, ) -> Expression<'ast>
pub fn static_block_keep_name_helper( &self, name: &'_ str, callee: Expression<'ast>, ) -> ClassElement<'ast>
pub fn simple_call_expr(&self, callee: Expression<'ast>) -> CallExpression<'ast>
pub fn alloc_simple_call_expr( &self, callee: Expression<'ast>, ) -> Box<'ast, CallExpression<'ast>>
pub fn object_freeze_dynamic_import_polyfill(&self) -> Expression<'ast>
Auto Trait Implementations§
impl<'ast> Freeze for AstSnippet<'ast>
impl<'ast> !RefUnwindSafe for AstSnippet<'ast>
impl<'ast> !Send for AstSnippet<'ast>
impl<'ast> !Sync for AstSnippet<'ast>
impl<'ast> Unpin for AstSnippet<'ast>
impl<'ast> !UnwindSafe for AstSnippet<'ast>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
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();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
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();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
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();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
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();
Source§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.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
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);