Skip to content

Commit 0c26524

Browse files
nhowellsteveklabnik
authored andcommitted
doc: Remove extra whitespace in the middle of lines to provide alignment
"Idiomatic code should not use extra whitespace in the middle of a line to provide alignment." http://aturon.github.io/style/whitespace.html I realize the linked page still needs an RFC, but the docs should be written in accordance with the guidelines nevertheless.
1 parent 34fa70f commit 0c26524

12 files changed

+70
-70
lines changed

src/doc/trpl/arrays-vectors-and-slices.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ things. The most basic is the *array*, a fixed-size list of elements of the
55
same type. By default, arrays are immutable.
66

77
```{rust}
8-
let a = [1, 2, 3]; // a: [i32; 3]
8+
let a = [1, 2, 3]; // a: [i32; 3]
99
let mut m = [1, 2, 3]; // mut m: [i32; 3]
1010
```
1111

@@ -68,7 +68,7 @@ let mut nums = vec![1, 2, 3]; // mut nums: Vec<i32>
6868
6969
nums.push(4);
7070
71-
println!("The length of nums is now {}", nums.len()); // Prints 4
71+
println!("The length of nums is now {}", nums.len()); // Prints 4
7272
```
7373

7474
Vectors have many more useful methods.
@@ -82,10 +82,10 @@ arrays:
8282

8383
```{rust}
8484
let a = [0, 1, 2, 3, 4];
85-
let middle = &a[1..4]; // A slice of a: just the elements 1, 2, and 3
85+
let middle = &a[1..4]; // A slice of a: just the elements 1, 2, and 3
8686
8787
for e in middle.iter() {
88-
println!("{}", e); // Prints 1, 2, 3
88+
println!("{}", e); // Prints 1, 2, 3
8989
}
9090
```
9191

src/doc/trpl/compound-data-types.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ arity and contained types.
5151

5252
```rust
5353
let mut x = (1, 2); // x: (i32, i32)
54-
let y = (2, 3); // y: (i32, i32)
54+
let y = (2, 3); // y: (i32, i32)
5555

5656
x = y;
5757
```
@@ -156,7 +156,7 @@ These two will not be equal, even if they have the same values:
156156
```{rust}
157157
# struct Color(i32, i32, i32);
158158
# struct Point(i32, i32, i32);
159-
let black = Color(0, 0, 0);
159+
let black = Color(0, 0, 0);
160160
let origin = Point(0, 0, 0);
161161
```
162162

src/doc/trpl/error-handling.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ fn probability(_: &Event) -> f64 {
6060
6161
fn descriptive_probability(event: Event) -> &'static str {
6262
match probability(&event) {
63-
1.00 => "certain",
64-
0.00 => "impossible",
63+
1.00 => "certain",
64+
0.00 => "impossible",
6565
0.00 ... 0.25 => "very unlikely",
6666
0.25 ... 0.50 => "unlikely",
6767
0.50 ... 0.75 => "likely",
68-
0.75 ... 1.00 => "very likely",
68+
0.75 ... 1.00 => "very likely",
6969
}
7070
}
7171
@@ -97,12 +97,12 @@ fn probability(_: &Event) -> f64 {
9797

9898
fn descriptive_probability(event: Event) -> &'static str {
9999
match probability(&event) {
100-
1.00 => "certain",
101-
0.00 => "impossible",
100+
1.00 => "certain",
101+
0.00 => "impossible",
102102
0.00 ... 0.25 => "very unlikely",
103103
0.25 ... 0.50 => "unlikely",
104104
0.50 ... 0.75 => "likely",
105-
0.75 ... 1.00 => "very likely",
105+
0.75 ... 1.00 => "very likely",
106106
_ => unreachable!()
107107
}
108108
}

src/doc/trpl/guessing-game.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ fn main() {
297297
println!("You guessed: {}", input);
298298
299299
match cmp(input, secret_number) {
300-
Ordering::Less => println!("Too small!"),
300+
Ordering::Less => println!("Too small!"),
301301
Ordering::Greater => println!("Too big!"),
302-
Ordering::Equal => println!("You win!"),
302+
Ordering::Equal => println!("You win!"),
303303
}
304304
}
305305
@@ -352,9 +352,9 @@ fn main() {
352352
println!("You guessed: {}", input);
353353

354354
match cmp(input, secret_number) {
355-
Ordering::Less => println!("Too small!"),
355+
Ordering::Less => println!("Too small!"),
356356
Ordering::Greater => println!("Too big!"),
357-
Ordering::Equal => println!("You win!"),
357+
Ordering::Equal => println!("You win!"),
358358
}
359359
}
360360

@@ -422,8 +422,8 @@ In this case, we say `x` is a `u32` explicitly, so Rust is able to properly
422422
tell `random()` what to generate. In a similar fashion, both of these work:
423423
424424
```{rust,ignore}
425-
let input_num = "5".parse::<u32>(); // input_num: Option<u32>
426-
let input_num: Option<u32> = "5".parse(); // input_num: Option<u32>
425+
let input_num = "5".parse::<u32>(); // input_num: Option<u32>
426+
let input_num: Option<u32> = "5".parse(); // input_num: Option<u32>
427427
```
428428
429429
Anyway, with us now converting our input to a number, our code looks like this:
@@ -450,9 +450,9 @@ fn main() {
450450
println!("You guessed: {}", input_num);
451451

452452
match cmp(input_num, secret_number) {
453-
Ordering::Less => println!("Too small!"),
453+
Ordering::Less => println!("Too small!"),
454454
Ordering::Greater => println!("Too big!"),
455-
Ordering::Equal => println!("You win!"),
455+
Ordering::Equal => println!("You win!"),
456456
}
457457
}
458458

@@ -499,7 +499,7 @@ fn main() {
499499
500500
let num = match input_num {
501501
Some(num) => num,
502-
None => {
502+
None => {
503503
println!("Please input a number!");
504504
return;
505505
}
@@ -509,9 +509,9 @@ fn main() {
509509
println!("You guessed: {}", num);
510510
511511
match cmp(num, secret_number) {
512-
Ordering::Less => println!("Too small!"),
512+
Ordering::Less => println!("Too small!"),
513513
Ordering::Greater => println!("Too big!"),
514-
Ordering::Equal => println!("You win!"),
514+
Ordering::Equal => println!("You win!"),
515515
}
516516
}
517517
@@ -566,7 +566,7 @@ fn main() {
566566
567567
let num = match input_num {
568568
Some(num) => num,
569-
None => {
569+
None => {
570570
println!("Please input a number!");
571571
return;
572572
}
@@ -576,9 +576,9 @@ fn main() {
576576
println!("You guessed: {}", num);
577577
578578
match cmp(num, secret_number) {
579-
Ordering::Less => println!("Too small!"),
579+
Ordering::Less => println!("Too small!"),
580580
Ordering::Greater => println!("Too big!"),
581-
Ordering::Equal => println!("You win!"),
581+
Ordering::Equal => println!("You win!"),
582582
}
583583
}
584584
@@ -642,7 +642,7 @@ fn main() {
642642

643643
let num = match input_num {
644644
Some(num) => num,
645-
None => {
645+
None => {
646646
println!("Please input a number!");
647647
return;
648648
}
@@ -652,9 +652,9 @@ fn main() {
652652
println!("You guessed: {}", num);
653653

654654
match cmp(num, secret_number) {
655-
Ordering::Less => println!("Too small!"),
655+
Ordering::Less => println!("Too small!"),
656656
Ordering::Greater => println!("Too big!"),
657-
Ordering::Equal => println!("You win!"),
657+
Ordering::Equal => println!("You win!"),
658658
}
659659
}
660660
}
@@ -718,7 +718,7 @@ fn main() {
718718
719719
let num = match input_num {
720720
Some(num) => num,
721-
None => {
721+
None => {
722722
println!("Please input a number!");
723723
return;
724724
}
@@ -728,9 +728,9 @@ fn main() {
728728
println!("You guessed: {}", num);
729729
730730
match cmp(num, secret_number) {
731-
Ordering::Less => println!("Too small!"),
731+
Ordering::Less => println!("Too small!"),
732732
Ordering::Greater => println!("Too big!"),
733-
Ordering::Equal => {
733+
Ordering::Equal => {
734734
println!("You win!");
735735
return;
736736
},
@@ -774,7 +774,7 @@ fn main() {
774774
775775
let num = match input_num {
776776
Some(num) => num,
777-
None => {
777+
None => {
778778
println!("Please input a number!");
779779
continue;
780780
}
@@ -784,9 +784,9 @@ fn main() {
784784
println!("You guessed: {}", num);
785785
786786
match cmp(num, secret_number) {
787-
Ordering::Less => println!("Too small!"),
787+
Ordering::Less => println!("Too small!"),
788788
Ordering::Greater => println!("Too big!"),
789-
Ordering::Equal => {
789+
Ordering::Equal => {
790790
println!("You win!");
791791
return;
792792
},
@@ -851,7 +851,7 @@ fn main() {
851851
852852
let num = match input_num {
853853
Some(num) => num,
854-
None => {
854+
None => {
855855
println!("Please input a number!");
856856
continue;
857857
}
@@ -861,9 +861,9 @@ fn main() {
861861
println!("You guessed: {}", num);
862862
863863
match cmp(num, secret_number) {
864-
Ordering::Less => println!("Too small!"),
864+
Ordering::Less => println!("Too small!"),
865865
Ordering::Greater => println!("Too big!"),
866-
Ordering::Equal => {
866+
Ordering::Equal => {
867867
println!("You win!");
868868
return;
869869
},

src/doc/trpl/iterators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ let greater_than_forty_two = range(0, 100)
143143
144144
match greater_than_forty_two {
145145
Some(_) => println!("We got some numbers!"),
146-
None => println!("No numbers found :("),
146+
None => println!("No numbers found :("),
147147
}
148148
```
149149

src/doc/trpl/looping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The other kind of looping construct in Rust is the `while` loop. It looks like
5454
this:
5555

5656
```{rust}
57-
let mut x = 5; // mut x: u32
57+
let mut x = 5; // mut x: u32
5858
let mut done = false; // mut done: bool
5959
6060
while !done {

src/doc/trpl/match.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ fn main() {
8484
let y = 10;
8585
8686
match cmp(x, y) {
87-
Ordering::Less => println!("less"),
87+
Ordering::Less => println!("less"),
8888
Ordering::Greater => println!("greater"),
89-
Ordering::Equal => println!("equal"),
89+
Ordering::Equal => println!("equal"),
9090
}
9191
}
9292
```
@@ -112,12 +112,12 @@ fn main() {
112112
113113
match x {
114114
OptionalInt::Value(n) => println!("x is {}", n),
115-
OptionalInt::Missing => println!("x is missing!"),
115+
OptionalInt::Missing => println!("x is missing!"),
116116
}
117117
118118
match y {
119119
OptionalInt::Value(n) => println!("y is {}", n),
120-
OptionalInt::Missing => println!("y is missing!"),
120+
OptionalInt::Missing => println!("y is missing!"),
121121
}
122122
}
123123
```
@@ -146,9 +146,9 @@ fn main() {
146146
let y = 10;
147147
148148
println!("{}", match cmp(x, y) {
149-
Ordering::Less => "less",
149+
Ordering::Less => "less",
150150
Ordering::Greater => "greater",
151-
Ordering::Equal => "equal",
151+
Ordering::Equal => "equal",
152152
});
153153
}
154154
```

src/doc/trpl/ownership.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -517,31 +517,31 @@ Here are some examples of functions with elided lifetimes, and the version of
517517
what the elided lifetimes are expand to:
518518

519519
```{rust,ignore}
520-
fn print(s: &str); // elided
521-
fn print<'a>(s: &'a str); // expanded
520+
fn print(s: &str); // elided
521+
fn print<'a>(s: &'a str); // expanded
522522
523-
fn debug(lvl: u32, s: &str); // elided
524-
fn debug<'a>(lvl: u32, s: &'a str); // expanded
523+
fn debug(lvl: u32, s: &str); // elided
524+
fn debug<'a>(lvl: u32, s: &'a str); // expanded
525525
526526
// In the preceeding example, `lvl` doesn't need a lifetime because it's not a
527527
// reference (`&`). Only things relating to references (such as a `struct`
528528
// which contains a reference) need lifetimes.
529529
530-
fn substr(s: &str, until: u32) -> &str; // elided
531-
fn substr<'a>(s: &'a str, until: u32) -> &'a str; // expanded
530+
fn substr(s: &str, until: u32) -> &str; // elided
531+
fn substr<'a>(s: &'a str, until: u32) -> &'a str; // expanded
532532
533-
fn get_str() -> &str; // ILLEGAL, no inputs
533+
fn get_str() -> &str; // ILLEGAL, no inputs
534534
535-
fn frob(s: &str, t: &str) -> &str; // ILLEGAL, two inputs
535+
fn frob(s: &str, t: &str) -> &str; // ILLEGAL, two inputs
536536
537-
fn get_mut(&mut self) -> &mut T; // elided
538-
fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded
537+
fn get_mut(&mut self) -> &mut T; // elided
538+
fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded
539539
540-
fn args<T:ToCStr>(&mut self, args: &[T]) -> &mut Command // elided
540+
fn args<T:ToCStr>(&mut self, args: &[T]) -> &mut Command // elided
541541
fn args<'a, 'b, T:ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command // expanded
542542
543-
fn new(buf: &mut [u8]) -> BufWriter; // elided
544-
fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a> // expanded
543+
fn new(buf: &mut [u8]) -> BufWriter; // elided
544+
fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a> // expanded
545545
```
546546

547547
# Related Resources

src/doc/trpl/patterns.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ let x = OptionalInt::Value(5);
6868
6969
match x {
7070
OptionalInt::Value(..) => println!("Got an int!"),
71-
OptionalInt::Missing => println!("No such luck."),
71+
OptionalInt::Missing => println!("No such luck."),
7272
}
7373
```
7474

@@ -85,7 +85,7 @@ let x = OptionalInt::Value(5);
8585
match x {
8686
OptionalInt::Value(i) if i > 5 => println!("Got an int bigger than five!"),
8787
OptionalInt::Value(..) => println!("Got an int!"),
88-
OptionalInt::Missing => println!("No such luck."),
88+
OptionalInt::Missing => println!("No such luck."),
8989
}
9090
```
9191

src/doc/trpl/pointers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ fn succ(x: &i32) -> i32 { *x + 1 }
463463
464464
let ref_x = &5;
465465
let box_x = Box::new(5);
466-
let rc_x = Rc::new(5);
466+
let rc_x = Rc::new(5);
467467
468468
succ(ref_x);
469469
succ(&*box_x);

0 commit comments

Comments
 (0)