Skip to main content

Settings

Struct Settings 

Source
pub struct Settings {
Show 41 fields pub version: PHPVersion, pub find_unused_expressions: bool, pub find_unused_definitions: bool, pub find_overly_wide_return_types: bool, pub analyze_dead_code: bool, pub memoize_properties: bool, pub allow_possibly_undefined_array_keys: bool, pub check_throws: bool, pub unchecked_exceptions: WordSet, pub unchecked_exception_classes: WordSet, pub check_missing_override: bool, pub find_unused_parameters: bool, pub strict_list_index_checks: bool, pub strict_array_index_existence: bool, pub allow_array_truthy_operand: bool, pub no_boolean_literal_comparison: bool, pub enforce_class_finality: bool, pub require_api_or_internal: bool, pub check_missing_type_hints: bool, pub check_closure_missing_type_hints: bool, pub check_arrow_function_missing_type_hints: bool, pub allow_implicit_pipe_callable_types: bool, pub register_super_globals: bool, pub use_colors: bool, pub diff: bool, pub trust_existence_checks: bool, pub class_initializers: Vec<ClassInitializer>, pub check_property_initialization: bool, pub check_use_statements: bool, pub check_experimental: bool, pub check_name_casing: bool, pub allow_side_effects_in_conditions: bool, pub saturation_complexity_threshold: u16, pub disjunction_complexity_threshold: u16, pub negation_complexity_threshold: u16, pub consensus_limit_threshold: u16, pub formula_size_threshold: u16, pub string_combination_threshold: u16, pub integer_combination_threshold: u16, pub array_combination_threshold: u16, pub loop_assignment_depth_threshold: u8,
}
Expand description

Configuration settings that control the behavior of the Mago analyzer.

This struct allows you to enable/disable specific checks, suppress categories of issues, and tune the analyzer’s performance and strictness.

Fields§

§version: PHPVersion

The target PHP version for the analysis.

§find_unused_expressions: bool

Find and report expressions whose results are not used (e.g., $a + $b;). Defaults to false.

§find_unused_definitions: bool

Find and report unused definitions (e.g., private methods that are never called). Defaults to false.

§find_overly_wide_return_types: bool

Warn when a function’s declared return type contains a branch the body never actually returns (e.g. : string|false on a function that always returns a string). Defaults to false.

§analyze_dead_code: bool

Analyze code that appears to be unreachable. Defaults to false.

§memoize_properties: bool

Track the literal values of class properties when they are assigned. This improves type inference but may increase memory usage. Defaults to true.

§allow_possibly_undefined_array_keys: bool

Allow accessing array keys that may not be defined without reporting an issue. Defaults to true.

§check_throws: bool

Enable checking for unhandled thrown exceptions.

When true, the analyzer will report any exception that is thrown but not caught in a try-catch block or documented in a @throws tag.

This check is disabled by default (false) as it can be computationally expensive.

§unchecked_exceptions: WordSet

Exceptions to ignore including all subclasses (hierarchy-aware).

When an exception class is in this set, any exception of that class or any of its subclasses will be ignored during check_throws analysis.

For example, adding LogicException will ignore LogicException, InvalidArgumentException, OutOfBoundsException, and all other subclasses.

§unchecked_exception_classes: WordSet

Exceptions to ignore (exact class match only, not subclasses).

When an exception class is in this set, only that exact class will be ignored during check_throws analysis. Parent classes and subclasses are not affected.

§check_missing_override: bool

Check for missing #[Override] attributes on overriding methods.

When enabled, the analyzer reports methods that override a parent method without the #[Override] attribute (PHP 8.3+).

Defaults to true.

§find_unused_parameters: bool

Find and report unused function/method parameters.

When enabled, the analyzer reports parameters that are declared but never used within the function body.

Defaults to true.

§strict_list_index_checks: bool

Enforce strict checks when accessing list elements by index.

When true, the analyzer requires that any integer used to access a list element is provably non-negative (e.g., of type int<0, max>). This helps prevent potential runtime errors from using a negative index.

When false (the default), any int is permitted as an index, offering more flexibility at the cost of type safety.

§strict_array_index_existence: bool

Treat array/list indices that are not provably present as T|null and warn on access.

When true, reading a key from any array-like type whose presence is not guaranteed emits possibly-undefined-int-array-index / possibly-undefined-string-array-index and the resulting type is widened to T|null. This applies to list<T> (non-zero indices), non-required entries of array{...} shapes, and array<K, V> lookups with arbitrary keys. It lets === null, ??, and ??= checks behave correctly against PHP’s runtime semantics — PHP turns missing reads into null with an Undefined array key warning.

When false (the default), the analyzer keeps the looser behavior: the value is flagged as possibly-undefined internally but is not unioned with null and no warning is emitted. This is friendlier for typical PHP code that destructures or reads from arrays/lists by index without first asserting existence.

§allow_array_truthy_operand: bool

Allow arrays as operands of logical operators (&&, ||, xor).

When true, the analyzer accepts an array on either side of a logical operator without emitting invalid-operand. PHP coerces empty arrays to false and non-empty arrays to true, mirroring the truthiness used by if ($array).

When false (the default), the analyzer flags array operands of &&/||/xor to call out the implicit bool coercion. This matches the long-standing default behavior; standalone if ($array) is still accepted and never produces this warning.

§no_boolean_literal_comparison: bool

Disable comparisons to boolean literals (true/false).

When enabled, comparisons to boolean literals will not be reported as issues.

Defaults to false.

§enforce_class_finality: bool

Enforce that concrete classes are declared final.

When enabled, the analyzer reports a warning for any class that is not final, abstract, or annotated with @api, provided the class has no children.

Defaults to false.

§require_api_or_internal: bool

Require @api or @internal annotations on abstract classes, interfaces, and traits.

When enabled, the analyzer reports a warning for any abstract class, interface, or trait that is not annotated with either @api or @internal.

Defaults to false.

§check_missing_type_hints: bool

Check for missing type hints on parameters, properties, and return types.

When enabled, the analyzer will report warnings for function parameters, class properties, and function return types that lack explicit type declarations. The analyzer uses its type system knowledge to avoid false positives - for instance, it won’t require a type hint on a property if adding one would conflict with a parent class or trait that has no type hint.

Defaults to false.

§check_closure_missing_type_hints: bool

Check for missing type hints (both parameters and return types) in closures when check_missing_type_hints is enabled.

When true, closures (anonymous functions declared with function() {}) will be checked for missing type hints. When false, closures are ignored, which is useful because closures often rely on type inference.

Defaults to false.

§check_arrow_function_missing_type_hints: bool

Check for missing type hints (both parameters and return types) in arrow functions when check_missing_type_hints is enabled.

When true, arrow functions (declared with fn() => ...) will be checked for missing type hints. When false, arrow functions are ignored, which is useful because arrow functions often rely on type inference and are typically short, making types obvious.

Defaults to false.

§allow_implicit_pipe_callable_types: bool

Skip the missing-type-hint checks for closures and arrow functions used directly as the right-hand side of the pipe operator (|>).

When true, an inline pipe callable like $x |> fn($p) => strtoupper($p) will not warn about its parameter or return type being missing, even when check-closure-missing-type-hints or check-arrow-function-missing-type-hints is on. The pipe operand’s type is enough to derive the parameter type, so requiring a hint here is mostly noise.

Defaults to false.

§register_super_globals: bool

Register superglobals (e.g., $_GET, $_POST, $_SERVER) in the analysis context.

If disabled, super globals won’t be available unless explicitly imported using the global keyword.

Defaults to true.

§use_colors: bool

Enable colored output in terminal environments that support it. Defaults to true.

This setting is primarily used for enabling/disabling colored diffs in issue reports.

§diff: bool

Internal use only.

Enables a diffing mode for incremental analysis, used by integrations like LSPs. This avoids re-analyzing unchanged code in the same session. Defaults to false.

§trust_existence_checks: bool

Trust symbol existence checks to narrow types.

When enabled, conditional checks like method_exists(), property_exists(), function_exists(), and defined() will narrow the type within the conditional block, suppressing errors for symbols that are verified to exist at runtime.

When disabled, these checks are ignored and the analyzer requires explicit type hints, which is stricter but may produce more false positives for dynamic code.

Defaults to true.

§class_initializers: Vec<ClassInitializer>

Method names treated as class initializers (like __construct).

Properties initialized in these methods count as “definitely initialized” just like in the constructor. This is useful for frameworks that use lifecycle methods like PHPUnit’s setUp() or framework boot() methods.

Entries can be either bare method names (applying to any class that has that method) or qualified as Fully\\Qualified\\Class::method to scope the rule to a specific class hierarchy.

Example: ["setUp", "boot", "PHPUnit\\Framework\\TestCase::setUpBeforeClass"]

Defaults to empty (no additional initializers).

§check_property_initialization: bool

Enable property initialization checking (missing-constructor, uninitialized-property).

When false, disables both missing-constructor and uninitialized-property issues entirely. This is useful for projects that prefer to rely on runtime errors for property initialization.

Defaults to false.

§check_use_statements: bool

Check for non-existent symbols in use statements.

When enabled, the analyzer will report use statements that import symbols (classes, interfaces, traits, enums, functions, or constants) that do not exist in the codebase.

Defaults to false.

§check_experimental: bool

Check for usage of @experimental symbols from non-experimental contexts.

When enabled, the analyzer reports warnings when a symbol marked @experimental is used from a context that is not itself marked @experimental.

Defaults to false.

§check_name_casing: bool

Check for incorrect casing when referencing classes, interfaces, traits, enums, and functions.

When enabled, the analyzer reports warnings when a symbol is referenced with different casing than its definition (e.g., new fooBar() when defined as FooBar). This helps prevent autoloading failures on case-sensitive file systems.

Defaults to false.

§allow_side_effects_in_conditions: bool

Whether to allow calls to impure functions inside conditions.

When set to false, any call to a function not marked @pure or @mutation-free inside an if, while, for, ternary, or match condition is reported. This helps catch surprising evaluation-order bugs where a side effect in one part of a condition silently alters a variable used in another part.

Defaults to true (impure calls in conditions are allowed).

§saturation_complexity_threshold: u16

Maximum number of clauses to process during CNF saturation.

Controls how many clauses the simplification algorithm will work with. If exceeded, saturation returns an empty result to avoid performance issues.

Defaults to 8192.

§disjunction_complexity_threshold: u16

Maximum number of clauses per side in disjunction operations.

Controls the complexity limit for OR operations between clause sets. If either side exceeds this, the disjunction returns an empty result.

Defaults to 4096.

§negation_complexity_threshold: u16

Maximum cumulative complexity during formula negation.

Controls how complex the negation of a formula can become. If exceeded, negation gives up to avoid exponential blowup.

Defaults to 4096.

§consensus_limit_threshold: u16

Upper limit for consensus optimization during saturation.

Controls when the consensus rule is applied during saturation. Only applies when clause count is between 3 and this limit.

Defaults to 256.

§formula_size_threshold: u16

Maximum logical formula size during conditional analysis.

Limits the size of generated formulas to prevent exponential blowup in deeply nested conditionals.

Defaults to 512.

§string_combination_threshold: u16

Maximum number of literal strings to track before generalizing.

When combining types with many different literal string values, tracking each literal individually causes O(n) memory and O(n²) comparison time. Once the threshold is exceeded, we generalize to the base string type.

Defaults to 128.

§integer_combination_threshold: u16

Maximum number of literal integers to track before generalizing.

When combining types with many different literal integer values, tracking each literal individually causes O(n) memory and O(n²) comparison time. Once the threshold is exceeded, we generalize to the base int type.

Defaults to 128.

§array_combination_threshold: u16

Maximum number of array elements to track individually.

When building array types through repeated push operations ($arr[] = ...), this limits how many individual elements are tracked before generalizing to a simpler array type. This prevents memory explosion on files with thousands of array pushes.

Defaults to 128.

§loop_assignment_depth_threshold: u8

Maximum depth of the loop assignment dependency graph that the fixed-point analyzer will explore when re-analysing loop bodies.

The analyzer uses fixed-point iteration to propagate widened types along loop-carried dependency chains. A chain of length N can require up to N extra passes for the type at the end of the chain to fully stabilise, and each pass re-analyses the entire loop body. On large, complex loops (think thousand-line procedural functions with deeply nested conditionals) the per-pass cost dominates file analysis time.

The default of 1 means each loop body is re-analysed at most once after the initial pass; enough to stabilise virtually all real-world code while keeping analysis cost bounded. Projects that require maximally precise narrowing of long loop-carried chains can raise this value (typically to 2 or 3) at the cost of significantly slower analysis on complex files.

Setting this to 0 disables fixed-point iteration entirely and analyses each loop body exactly once. This is the fastest option but may produce less precise types for variables that depend on themselves across iterations.

Defaults to 1.

Implementations§

Source§

impl Settings

Source

pub fn new(version: PHPVersion) -> Self

Source

pub fn algebra_thresholds(&self) -> AlgebraThresholds

Returns the algebra thresholds derived from the settings.

Source

pub fn combiner_options(&self) -> CombinerOptions

Returns the combiner options derived from the settings.

Source

pub fn is_class_initializer_for( &self, meta: &ClassLikeMetadata, method_name: Word, ) -> bool

Returns true when method_name is a configured class initializer applicable to meta (either an unrestricted entry, or one whose class qualifier meta is a subclass/implementer of).

Source

pub fn applicable_class_initializers<'cfg>( &'cfg self, meta: &'cfg ClassLikeMetadata, ) -> impl Iterator<Item = Word> + 'cfg

Iterator over initializer method names applicable to meta.

Trait Implementations§

Source§

impl Clone for Settings

Source§

fn clone(&self) -> Settings

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Settings

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Settings

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Settings

Source§

impl PartialEq for Settings

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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.
Source§

impl StructuralPartialEq for Settings

Auto Trait Implementations§

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
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

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

Source§

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 primary(&self) -> Painted<&T>

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

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

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

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

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

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));
Source§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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>

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

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

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

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

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

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));
Source§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 bold(&self) -> Painted<&T>

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

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

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

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

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

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

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

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

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());
Source§

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

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

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

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

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

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

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

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

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

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 mask(&self) -> Painted<&T>

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

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

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

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

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

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

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

§Example
println!("{}", value.linger());
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.

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

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

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

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

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

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

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

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

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

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

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

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);
Source§

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

Create a new Painted with a default Style. Read more
Source§

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more