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 a number of cases, rustfmt produces poor formatting in code that has a combination of arithmetic infix operators and method calls (using dot). I've collected a few examples that I hope will be helpful.
Example 1
In this case, it's difficult to see what is wrapped in the parentheses starting after 0.5 * and what the .scalar_sum applies to:
This example is similar. It's quite hard to understand, largely because it's not clear where the corresponding closing parenthesis is for the opening parenthesis after c *. At first glance, the indentation makes it look like the - and + are happening at the same level as the *, but in fact, they are inside the right-hand-side expression of the *.
This example isn't quite as bad as the others, but it's somewhat difficult to see what the .sum_axis is being applied to. The indentation suggests that it's at the same level as the *, but in fact, it's applied to the parenthesized expression containing the *.
fnmain(){{let tdX:Array1<_> = -0.5* t
*(&iR.t()* test_covariance
*(-2.*&inv_sq_len_scales_i - 2.*&inv_sq_len_scales_i)).sum_axis(Axis(0));}}
It would be clearer with something like this:
fnmain(){{let tdX:Array1<_> = -0.5* t
*(&iR.t()* test_covariance
*(-2.*&inv_sq_len_scales_i - 2.*&inv_sq_len_scales_i)).sum_axis(Axis(0));}}
or this:
fnmain(){{let tdX:Array1<_> = -0.5* t
*(&iR.t()* test_covariance
*(-2.*&inv_sq_len_scales_i - 2.*&inv_sq_len_scales_i)).sum_axis(Axis(0));}}
Example 4
This is another similar example. It's not clear what the .dot is being applied to. (Is it applied to an expression containing the *, or is it applied to the expression on the right-hand-side of the *?)
In a number of cases,
rustfmt
produces poor formatting in code that has a combination of arithmetic infix operators and method calls (using dot). I've collected a few examples that I hope will be helpful.Example 1
In this case, it's difficult to see what is wrapped in the parentheses starting after
0.5 *
and what the.scalar_sum
applies to:It would be much easier to understand with something like this:
Example 2
This example is similar. It's quite hard to understand, largely because it's not clear where the corresponding closing parenthesis is for the opening parenthesis after
c *
. At first glance, the indentation makes it look like the-
and+
are happening at the same level as the*
, but in fact, they are inside the right-hand-side expression of the*
.It would be much easier to understand with something like this:
Example 3
This example isn't quite as bad as the others, but it's somewhat difficult to see what the
.sum_axis
is being applied to. The indentation suggests that it's at the same level as the*
, but in fact, it's applied to the parenthesized expression containing the*
.It would be clearer with something like this:
or this:
Example 4
This is another similar example. It's not clear what the
.dot
is being applied to. (Is it applied to an expression containing the*
, or is it applied to the expression on the right-hand-side of the*
?)It would be clearer like this:
or this:
The text was updated successfully, but these errors were encountered: