pub struct FmtConfig {
pub use_tabs: bool,
pub indent_size: usize,
pub line_width: usize,
pub normalize_spacing: bool,
pub collapse_blank_lines: bool,
pub insert_blank_lines: bool,
pub reflow: bool,
pub normalize_strings: bool,
pub expand_inline_blocks: bool,
pub strip_parens: bool,
pub collapse_lambdas: bool,
pub safe_mode: bool,
}Expand description
Formatter options. Defaults match the Godot convention (tabs) and keep the safety net on.
Fields§
§use_tabs: boolIndent with tabs (the Godot convention). false indents with indent_size spaces.
indent_size: usizeSpaces per indent level when use_tabs is false.
line_width: usizeThe target line width for reflow (default 100).
normalize_spacing: boolNormalize intra-line spacing between tokens (one space around binary operators, after
,/:, hugged brackets, tight member access + unary). On by default. Turn off to format
indentation only (the pre-increment-A behavior).
collapse_blank_lines: boolCollapse runs of blank lines (max 2 at top level, max 1 inside a block) and strip leading blank lines. On by default.
insert_blank_lines: boolInsert blank lines around definitions to match gdformat (2 around top-level func/class/
static func, 1 around nested ones; comments/annotations attached to a def move with it). On
by default. Purely additive — never changes the significant token sequence.
reflow: boolWrap a single-line statement that exceeds line_width and contains a
bracketed group (call / array / dict / parameter list) — flat → compact → exploded, matching
gdformat’s length-driven layout. On by default. Token-preserving (no trailing comma added).
normalize_strings: boolNormalize string-literal quotes to gdformat’s style: prefer ", fall back to ' only when
the body has more " than '. On by default. Preserves the string’s value (a token-mutating
rewrite guarded by the meaning-equivalence net).
expand_inline_blocks: boolSplit an inline suite body onto its own indented line (if c: x → if c: / x,
func f(): return → split, a; b → two lines), matching gdformat. An inline lambda body
(func(): x) is preserved. On by default. Token-preserving (adds only newlines/indent).
strip_parens: boolRemove redundant grouping parens from a standalone-expression position — a var/const/return
value, a for iterable, an if/while condition, a call argument, an array/dict element, a
nested (…) — matching gdformat’s remove_outer_parentheses. Precedence-significant parens
((a + b) * c) are kept. On by default. Token-mutating; guarded by the meaning-equivalence net.
collapse_lambdas: boolCollapse a multi-line lambda whose body is a single simple statement onto one line
(func():\n\tbody → func(): body), matching gdformat, so the surrounding statement can re-flow
(and often fit on one line). On by default. Token-preserving (removes only a newline/indent).
safe_mode: boolRe-parse + significant-token-equality fallback to verbatim. Keep on unless you have a reason not to: it is the guarantee the formatter never changes meaning.
Trait Implementations§
impl Eq for FmtConfig
impl StructuralPartialEq for FmtConfig
Auto Trait Implementations§
impl Freeze for FmtConfig
impl RefUnwindSafe for FmtConfig
impl Send for FmtConfig
impl Sync for FmtConfig
impl Unpin for FmtConfig
impl UnsafeUnpin for FmtConfig
impl UnwindSafe for FmtConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.