Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spaces_within_square_brackets config option. (#1191)
* Add spaces_within_square_brackets config option. Enabling the config enforces spaces within various array/slice brackets. * Fixed budget-calculations for [] spacing
- Loading branch information
Showing
6 changed files
with
105 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// rustfmt-spaces_within_square_brackets: true | ||
|
||
fn main() { | ||
|
||
let arr: [i32; 5] = [1, 2, 3, 4, 5]; | ||
let arr: [i32; 500] = [0; 500]; | ||
|
||
let v = vec![1, 2, 3]; | ||
assert_eq!(arr, [1, 2, 3]); | ||
|
||
let i = arr[0]; | ||
|
||
let slice = &arr[1..2]; | ||
|
||
let line100_________________________________________________________________________ = [1, 2]; | ||
let line101__________________________________________________________________________ = [1, 2]; | ||
let line102___________________________________________________________________________ = [1, 2]; | ||
let line103____________________________________________________________________________ = [1, 2]; | ||
let line104_____________________________________________________________________________ = [1, 2]; | ||
|
||
let line100_____________________________________________________________________ = vec![1, 2]; | ||
let line101______________________________________________________________________ = vec![1, 2]; | ||
let line102_______________________________________________________________________ = vec![1, 2]; | ||
let line103________________________________________________________________________ = vec![1, 2]; | ||
let line104_________________________________________________________________________ = vec![1, 2]; | ||
} | ||
|
||
fn f(slice: &[i32]) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// rustfmt-spaces_within_square_brackets: true | ||
|
||
fn main() { | ||
|
||
let arr: [ i32; 5 ] = [ 1, 2, 3, 4, 5 ]; | ||
let arr: [ i32; 500 ] = [ 0; 500 ]; | ||
|
||
let v = vec![ 1, 2, 3 ]; | ||
assert_eq!(arr, [ 1, 2, 3 ]); | ||
|
||
let i = arr[ 0 ]; | ||
|
||
let slice = &arr[ 1..2 ]; | ||
|
||
let line100_________________________________________________________________________ = [ 1, 2 ]; | ||
let line101__________________________________________________________________________ = [ 1, | ||
2 ]; | ||
let line102___________________________________________________________________________ = [ 1, | ||
2 ]; | ||
let line103____________________________________________________________________________ = [ 1, | ||
2 ]; | ||
let line104_____________________________________________________________________________ = | ||
[ 1, 2 ]; | ||
|
||
let line100_____________________________________________________________________ = vec![ 1, 2 ]; | ||
let line101______________________________________________________________________ = vec![ 1, | ||
2 ]; | ||
let line102_______________________________________________________________________ = vec![ 1, | ||
2 ]; | ||
let line103________________________________________________________________________ = vec![ 1, | ||
2 ]; | ||
let line104_________________________________________________________________________ = | ||
vec![ 1, 2 ]; | ||
} | ||
|
||
fn f(slice: &[ i32 ]) {} |