FormatSettings

Struct FormatSettings 

Source
pub struct FormatSettings {
Show 72 fields pub print_width: usize, pub tab_width: usize, pub use_tabs: bool, pub end_of_line: EndOfLine, pub single_quote: bool, pub trailing_comma: bool, pub remove_trailing_close_tag: bool, pub control_brace_style: BraceStyle, pub closure_brace_style: BraceStyle, pub function_brace_style: BraceStyle, pub method_brace_style: BraceStyle, pub classlike_brace_style: BraceStyle, pub inline_empty_control_braces: bool, pub inline_empty_closure_braces: bool, pub inline_empty_function_braces: bool, pub inline_empty_method_braces: bool, pub inline_empty_constructor_braces: bool, pub inline_empty_classlike_braces: bool, pub inline_empty_anonymous_class_braces: bool, pub method_chain_breaking_style: MethodChainBreakingStyle, pub first_method_chain_on_new_line: bool, pub preserve_breaking_member_access_chain: bool, pub preserve_breaking_argument_list: bool, pub preserve_breaking_array_like: bool, pub preserve_breaking_parameter_list: bool, pub preserve_breaking_attribute_list: bool, pub preserve_breaking_conditional_expression: bool, pub break_promoted_properties_list: bool, pub line_before_binary_operator: bool, pub always_break_named_arguments_list: bool, pub always_break_attribute_named_argument_lists: bool, pub array_table_style_alignment: bool, pub align_assignment_like: bool, pub sort_uses: bool, pub sort_class_methods: bool, pub separate_use_types: bool, pub expand_use_groups: bool, pub null_type_hint: NullTypeHint, pub parentheses_around_new_in_member_access: bool, pub parentheses_in_new_expression: bool, pub parentheses_in_exit_and_die: bool, pub parentheses_in_attribute: bool, pub space_before_arrow_function_parameter_list_parenthesis: bool, pub space_before_closure_parameter_list_parenthesis: bool, pub space_before_hook_parameter_list_parenthesis: bool, pub space_before_closure_use_clause_parenthesis: bool, pub space_after_cast_unary_prefix_operators: bool, pub space_after_reference_unary_prefix_operator: bool, pub space_after_error_control_unary_prefix_operator: bool, pub space_after_logical_not_unary_prefix_operator: bool, pub space_after_bitwise_not_unary_prefix_operator: bool, pub space_after_increment_unary_prefix_operator: bool, pub space_after_decrement_unary_prefix_operator: bool, pub space_after_additive_unary_prefix_operator: bool, pub space_around_concatenation_binary_operator: bool, pub space_around_assignment_in_declare: bool, pub space_within_grouping_parenthesis: bool, pub empty_line_after_control_structure: bool, pub empty_line_after_opening_tag: bool, pub empty_line_after_declare: bool, pub empty_line_after_namespace: bool, pub empty_line_after_use: bool, pub empty_line_after_symbols: bool, pub empty_line_between_same_symbols: bool, pub empty_line_after_class_like_constant: bool, pub empty_line_after_enum_case: bool, pub empty_line_after_trait_use: bool, pub empty_line_after_property: bool, pub empty_line_after_method: bool, pub empty_line_before_return: bool, pub empty_line_before_dangling_comments: bool, pub separate_class_like_members: bool,
}
Expand description

Format settings for the PHP printer.

Fields§

§print_width: usize

Maximum line length that the printer will wrap on.

Default: 120

§tab_width: usize

Number of spaces per indentation level.

Default: 4

§use_tabs: bool

Whether to use tabs instead of spaces for indentation.

Default: false

§end_of_line: EndOfLine

End-of-line characters to use.

Default: “lf”

§single_quote: bool

Whether to use single quotes instead of double quotes for strings.

The formatter automatically determines which quotes to use based on the string content, with a preference for single quotes if this option is enabled.

Decision logic:

  • If the string contains more single quotes than double quotes, double quotes are used
  • If the string contains more double quotes than single quotes, single quotes are used
  • If equal number of both, single quotes are used if this option is true

Default: true

§trailing_comma: bool

Whether to add a trailing comma to the last element in multi-line syntactic structures.

When enabled, trailing commas are added to lists, arrays, parameter lists, argument lists, and other similar structures when they span multiple lines.

Default: true

§remove_trailing_close_tag: bool

Whether to remove the trailing PHP close tag (?>) from files.

Default: true

§control_brace_style: BraceStyle

Brace placement for control structures (if, for, while, etc.).

Example with same_line:

if ($expr) {
    return 'Hello, world!';
}

Example with next_line:

if ($expr)
{
    return 'Hello, world!';
}

Default: same_line

§closure_brace_style: BraceStyle

Brace placement for closures.

Example with same_line:

$closure = function() {
    return 'Hello, world!';
};

Example with next_line:

$closure = function()
{
    return 'Hello, world!';
};

Default: same_line

§function_brace_style: BraceStyle

Brace placement for function declarations.

Example with same_line:

function foo() {
    return 'Hello, world!';
}

Example with next_line:

function foo()
{
    return 'Hello, world!';
}

Default: next_line

§method_brace_style: BraceStyle

Brace placement for method declarations.

Example with same_line:

class Foo
{
    public function bar() {
        return 'Hello, world!';
    }
}

Example with next_line:

class Foo
{
    public function bar()
    {
        return 'Hello, world!';
    }
}

Default: next_line

§classlike_brace_style: BraceStyle

Brace placement for class-like structures (classes, interfaces, traits, enums).

Example with same_line:

class Foo {
}

Example with next_line:

class Foo
{
}

Default: next_line

§inline_empty_control_braces: bool

Place empty control structure bodies on the same line.

Example with false:

if ($expr)
{
}

Example with true:

if ($expr) {}

Default: false

§inline_empty_closure_braces: bool

Place empty closure bodies on the same line.

Example with false:

$closure = function()
{
};

Example with true:

$closure = function() {};

Default: true

§inline_empty_function_braces: bool

Place empty function bodies on the same line.

Example with false:

function foo()
{
}

Example with true:

function foo() {}

Default: false

§inline_empty_method_braces: bool

Place empty method bodies on the same line.

Example with false:

class Foo
{
    public function bar()
    {
    }
}

Example with true:

class Foo
{
    public function bar() {}
}

Default: false

§inline_empty_constructor_braces: bool

Place empty constructor bodies on the same line.

Example with false:

class Foo {
    public function __construct()
    {
    }
}

Example with true:

class Foo {
    public function __construct() {}
}

Default: true

§inline_empty_classlike_braces: bool

Place empty class-like bodies on the same line.

Example with false:

class Foo
{
}

Example with true:

class Foo {}

Default: true

§inline_empty_anonymous_class_braces: bool

Place empty anonymous class bodies on the same line.

Example with false:

$anon = new class
{
};

Example with true:

$anon = new class {};

Default: true

§method_chain_breaking_style: MethodChainBreakingStyle

How to format broken method/property chains.

When next_line, the first method/property starts on a new line:

$foo
    ->bar()
    ->baz();

When same_line, the first method/property stays on the same line:

$foo->bar()
    ->baz();

Default: next_line

§first_method_chain_on_new_line: bool

When method chaining breaks across lines, place the first method on a new line.

This follows PER-CS 4.7: “When [method chaining is] put on separate lines, […] the first method MUST be on the next line.”

When enabled:

$this
    ->getCache()
    ->forget();

When disabled:

$this->getCache()
    ->forget();

Default: true

§preserve_breaking_member_access_chain: bool

Whether to preserve line breaks in method chains, even if they could fit on a single line.

Default: false

§preserve_breaking_argument_list: bool

Whether to preserve line breaks in argument lists, even if they could fit on a single line.

Default: false

§preserve_breaking_array_like: bool

Whether to preserve line breaks in array-like structures, even if they could fit on a single line.

Default: true

§preserve_breaking_parameter_list: bool

Whether to preserve line breaks in parameter lists, even if they could fit on a single line.

Default: false

§preserve_breaking_attribute_list: bool

Whether to preserve line breaks in attribute lists, even if they could fit on a single line.

Default: false

§preserve_breaking_conditional_expression: bool

Whether to preserve line breaks in conditional (ternary) expressions.

Default: false

§break_promoted_properties_list: bool

Whether to break a parameter list with one or more promoted properties into multiple lines.

When enabled, parameter lists with promoted properties are always multi-line:

class User {
    public function __construct(
        public string $name,
        public string $email,
    ) {}
}

When disabled, they may be kept on a single line if space allows:

class User {
    public function __construct(public string $name, public string $email) {}
}

Default: true

§line_before_binary_operator: bool

Whether to add a line before binary operators or after when breaking.

When true:

$foo = 'Hello, '
    . 'world!';

When false:

$foo = 'Hello, ' .
    'world!';

Note: If the right side has a leading comment, this setting is always false.

Default: true

§always_break_named_arguments_list: bool

Whether to always break named argument lists into multiple lines.

When enabled:

$foo = some_function(
    argument1: 'value1',
    argument2: 'value2',
);

Default: false

§always_break_attribute_named_argument_lists: bool

Whether to always break named argument lists in attributes into multiple lines.

When enabled:

#[SomeAttribute(
    argument1: 'value1',
    argument2: 'value2',
)]
class Foo {}

Default: false

§array_table_style_alignment: bool

Whether to use table-style alignment for arrays.

When enabled, array elements are aligned in a table-like format:

$array = [
    ['foo',  1.2,  123, false],
    ['bar',  52.4, 456, true],
    ['baz',  3.6,  789, false],
    ['qux',  4.8,    1, true],
    ['quux', 5.0,   12, false],
];

Default: true

§align_assignment_like: bool

Whether to align consecutive assignment-like constructs in columns.

When enabled, consecutive variable assignments, class properties, class constants, global constants, array key-value pairs, and backed enum cases are column-aligned.

Example with true:

$foo     = 1;
$b       = 2;
$ccccccc = 3;

class X {
    public string       $foo    = 1;
    public readonly int $barrrr = 2;
}

Example with false:

$foo = 1;
$b = 2;
$ccccccc = 3;

Note: Blank lines and comments break alignment runs. In class bodies, different member types (properties vs constants) are aligned separately.

Default: false

§sort_uses: bool

Whether to sort use statements alphabetically.

Default: true

§sort_class_methods: bool

Whether to sort class methods by visibility and name.

When enabled, methods in class-like structures are automatically reordered:

  1. Constructor (__construct) - always first
  2. Static methods (by visibility: public, protected, private)
    • Abstract methods before concrete methods
    • Alphabetically by name within each group
  3. Instance methods (by visibility: public, protected, private)
    • Abstract methods before concrete methods
    • Alphabetically by name within each group
  4. Other magic methods (e.g., __toString, __get, __set)
    • Sorted alphabetically by name
  5. Destructor (__destruct) - always last

This applies to all class-like structures: classes, traits, interfaces, and enums. Other members (constants, properties, trait uses, enum cases) remain in their original positions.

Default: false

§separate_use_types: bool

Whether to insert a blank line between different types of use statements.

When enabled:

use Foo\Bar;
use Foo\Baz;

use function Foo\bar;
use function Foo\baz;

use const Foo\A;
use const Foo\B;

When disabled:

use Foo\Bar;
use Foo\Baz;
use function Foo\bar;
use function Foo\baz;
use const Foo\A;
use const Foo\B;

Default: true

§expand_use_groups: bool

Whether to expand grouped use statements into individual statements.

When enabled:

use Foo\Bar;
use Foo\Baz;

When disabled:

use Foo\{Bar, Baz};

Default: true

§null_type_hint: NullTypeHint

How to format null type hints.

With Question:

function foo(?string $bar) {
    return $bar;
}

With NullPipe:

function foo(null|string $bar) {
    return $bar;
}

Default: Question

§parentheses_around_new_in_member_access: bool

Whether to include parentheses around new when followed by a member access.

Controls whether to use PHP 8.4’s shorthand syntax for new expressions followed by member access. If PHP version is earlier than 8.4, this is always true.

When enabled:

$foo = (new Foo)->bar();

When disabled (PHP 8.4+ only):

$foo = new Foo->bar();

Default: false

§parentheses_in_new_expression: bool

Whether to include parentheses in new expressions when no arguments are provided.

When enabled:

$foo = new Foo();

When disabled:

$foo = new Foo;

Default: true

§parentheses_in_exit_and_die: bool

Whether to include parentheses in exit and die constructs.

When enabled:

exit();
die();

When disabled:

exit;
die;

Default: true

§parentheses_in_attribute: bool

Whether to include parentheses in attributes with no arguments.

When enabled:

#[SomeAttribute()]
class Foo {}

When disabled:

#[SomeAttribute]
class Foo {}

Default: false

§space_before_arrow_function_parameter_list_parenthesis: bool

Whether to add a space before the opening parameters in arrow functions.

When enabled: fn ($x) => $x * 2 When disabled: fn($x) => $x * 2

Default: false

§space_before_closure_parameter_list_parenthesis: bool

Whether to add a space before the opening parameters in closures.

When enabled: function ($x) use ($y) When disabled: function($x) use ($y)

Default: true

§space_before_hook_parameter_list_parenthesis: bool

Whether to add a space before the opening parameters in hooks.

When enabled: $hook ($param) When disabled: $hook($param)

Default: false

§space_before_closure_use_clause_parenthesis: bool

Whether to add a space before the opening parenthesis in closure use clause.

When enabled: function() use ($var) When disabled: function() use($var)

Default: true

§space_after_cast_unary_prefix_operators: bool

Whether to add a space after cast operators (int, float, string, etc.).

When enabled: (int) $foo When disabled: (int)$foo

Default: true

§space_after_reference_unary_prefix_operator: bool

Whether to add a space after the reference operator (&).

When enabled: & $foo When disabled: &$foo

Default: false

§space_after_error_control_unary_prefix_operator: bool

Whether to add a space after the error control operator (@).

When enabled: @ $foo When disabled: @$foo

Default: false

§space_after_logical_not_unary_prefix_operator: bool

Whether to add a space after the logical not operator (!).

When enabled: ! $foo When disabled: !$foo

Default: false

§space_after_bitwise_not_unary_prefix_operator: bool

Whether to add a space after the bitwise not operator (~).

When enabled: ~ $foo When disabled: ~$foo

Default: false

§space_after_increment_unary_prefix_operator: bool

Whether to add a space after the increment prefix operator (++).

When enabled: ++ $i When disabled: ++$i

Default: false

§space_after_decrement_unary_prefix_operator: bool

Whether to add a space after the decrement prefix operator (–).

When enabled: -- $i When disabled: --$i

Default: false

§space_after_additive_unary_prefix_operator: bool

Whether to add a space after the additive unary operators (+ and -).

When enabled: + $i When disabled: +$i

Default: false

§space_around_concatenation_binary_operator: bool

Whether to add spaces around the concatenation operator (.)

When enabled: $a . $b When disabled: $a.$b

Default: true

§space_around_assignment_in_declare: bool

Whether to add spaces around the assignment in declare statements.

When enabled: declare(strict_types = 1) When disabled: declare(strict_types=1)

Default: false

§space_within_grouping_parenthesis: bool

Whether to add spaces within grouping parentheses.

When enabled: ( $expr ) - $expr When disabled: ($expr) - $expr

Default: false

§empty_line_after_control_structure: bool

Whether to add an empty line after control structures (if, for, foreach, while, do, switch).

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: false

§empty_line_after_opening_tag: bool

Whether to add an empty line after opening tag.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: true

§empty_line_after_declare: bool

Whether to add an empty line after declare statement.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: true

§empty_line_after_namespace: bool

Whether to add an empty line after namespace.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: true

§empty_line_after_use: bool

Whether to add an empty line after use statements.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: true

§empty_line_after_symbols: bool

Whether to add an empty line after symbols (class, enum, interface, trait, function, const).

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: true

§empty_line_between_same_symbols: bool

Whether to add an empty line between consecutive symbols of the same type.

Only applies when empty_line_after_symbols is true.

Default: true

§empty_line_after_class_like_constant: bool

Whether to add an empty line after class-like constant.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: false

§empty_line_after_enum_case: bool

Whether to add an empty line after enum case.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: false

§empty_line_after_trait_use: bool

Whether to add an empty line after trait use.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: false

§empty_line_after_property: bool

Whether to add an empty line after property.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: false

§empty_line_after_method: bool

Whether to add an empty line after method.

Note: if an empty line already exists, it will be preserved regardless of this settings value.

Default: true

§empty_line_before_return: bool

Whether to add an empty line before return statements.

Default: false

§empty_line_before_dangling_comments: bool

Whether to add an empty line before dangling comments.

Default: true

§separate_class_like_members: bool

Whether to separate class-like members of different kinds with a blank line.

Default: true

Trait Implementations§

Source§

impl Clone for FormatSettings

Source§

fn clone(&self) -> FormatSettings

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FormatSettings

Source§

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

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

impl Default for FormatSettings

Source§

fn default() -> Self

Sets default values to align with best practices.

Source§

impl<'de> Deserialize<'de> for FormatSettings

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl Hash for FormatSettings

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonSchema for FormatSettings

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Ord for FormatSettings

Source§

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

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

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for FormatSettings

Source§

fn eq(&self, other: &FormatSettings) -> 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.
Source§

impl PartialOrd for FormatSettings

Source§

fn partial_cmp(&self, other: &FormatSettings) -> 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
Source§

impl Serialize for FormatSettings

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

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

impl Copy for FormatSettings

Source§

impl Eq for FormatSettings

Source§

impl StructuralPartialEq for FormatSettings

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
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

Checks if this value is equivalent to the given key. Read more
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,