You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In programming, arrays of data are sometimes formatted with X values per line, usually a multiple of 10 or 2. This allows you to easily find and inspect the data of a specific index by counting the lines and values on the target line.
The number of values per line depends on the nature of the data, so a global config is basically a default. You also need a way to set the config of individual arrays.
Currently I have to use #[rustfmt::skip] and format it manually, but I really want it to be automatic.
attribute-driven formatting is a risky proposition for rustfmt, particularly given the existing set of features like formatting a single file or a subset of lines within the file and the results needing to be deterministic regardless of scope.
so while it's widely recognized that the existing style rules and corresponding rustfmt formatting behavior are not great for certain constructs like large arrays, matrices, etc., i don't think attribute-based formatting rules will be a viable option.
it's a topic the style team is likely to take under consideration for the 2027 edition, and something i think rustfmt needs to first see if we can format "better" before we consider going to the extreme of allowing user control over one array to the next
In programming, arrays of data are sometimes formatted with X values per line, usually a multiple of 10 or 2. This allows you to easily find and inspect the data of a specific index by counting the lines and values on the target line.
The number of values per line depends on the nature of the data, so a global config is basically a default. You also need a way to set the config of individual arrays.
Currently I have to use
#[rustfmt::skip]
and format it manually, but I really want it to be automatic.Example:
If possible I would like an option to set the maximum number of array values per line and an attribute to configure individual arrays. Something like:
If you feel like it, an option that aligns values "vertically" (to the left, to the right or centered) is welcome. 😉
The text was updated successfully, but these errors were encountered: