#[non_exhaustive]pub struct ScriptFormatConfig {
pub margin: u16,
pub inline: u16,
pub indent: u16,
pub preserve_expr_groups: bool,
pub preserve_blank_lines: bool,
pub preserve_blocks: bool,
pub compact_blocks: bool,
}Expand description
Configuration options for the Ad Astra script formatting utility.
Used as an argument for the format_script_text and ModuleText::format functions.
The Default implementation of this object provides canonical configuration options, though you can customize some formatting options at your discretion.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.margin: u16The number of characters the formatter should keep in a line before breaking the content into multiple lines.
The default value is 80.
inline: u16If the formatter breaks a line into multiple lines, it should attempt
to keep at least the inline number of characters in each line,
relative to the current indentation.
The default value is 60.
indent: u16The number of whitespace characters for a single level of indentation.
The default value is 4.
preserve_expr_groups: boolIf set to true, the formatter preserves excessive parentheses in expressions.
For example, the formatter will keep the expression (1 + 2) + 3 as it
is, even though it could otherwise be rewritten as 1 + 2 + 3.
The default value is false, meaning that the formatter will attempt
to remove unnecessary parentheses whenever possible.
preserve_blank_lines: boolIf set to true, the formatter preserves at most one blank line between script code statements. Otherwise, the formatter will eliminate excessive blank lines.
The default value is true.
preserve_blocks: boolIf set to true, the formatter preserves statement blocks even if they could clearly be merged into the surrounding code.
For example, the formatter will keep the code foo(); { bar(); } baz();
as it is, even though it could otherwise be rewritten as
foo(); bar(); baz();.
The default value is false, meaning that the formatter will attempt
to merge blocks together.
compact_blocks: boolWhen set to true, the formatter attempts to keep short code blocks in line.
For example, the formatter will keep the code { foo(); } in line
instead of breaking it into three lines:
{
foo();
}The default value is false, meaning that the formatter will typically
break single-statement blocks into multiple lines.
Implementations§
Trait Implementations§
Source§impl Clone for ScriptFormatConfig
impl Clone for ScriptFormatConfig
Source§fn clone(&self) -> ScriptFormatConfig
fn clone(&self) -> ScriptFormatConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ScriptFormatConfig
Source§impl Debug for ScriptFormatConfig
impl Debug for ScriptFormatConfig
Source§impl Default for ScriptFormatConfig
impl Default for ScriptFormatConfig
impl Eq for ScriptFormatConfig
Source§impl Hash for ScriptFormatConfig
impl Hash for ScriptFormatConfig
Source§impl PartialEq for ScriptFormatConfig
impl PartialEq for ScriptFormatConfig
Source§fn eq(&self, other: &ScriptFormatConfig) -> bool
fn eq(&self, other: &ScriptFormatConfig) -> bool
self and other values to be equal, and is used by ==.