@@ -1095,12 +1095,12 @@ typecheck:
10951095# fn my_err(s: &str) -> ! { panic!() }
10961096
10971097fn f(i: i32) -> i32 {
1098- if i == 42 {
1099- return 42;
1100- }
1101- else {
1102- my_err("Bad number!");
1103- }
1098+ if i == 42 {
1099+ return 42;
1100+ }
1101+ else {
1102+ my_err("Bad number!");
1103+ }
11041104}
11051105```
11061106
@@ -1399,9 +1399,9 @@ functions](#generic-functions).
13991399
14001400```
14011401trait Seq<T> {
1402- fn len(&self) -> u32;
1403- fn elt_at(&self, n: u32) -> T;
1404- fn iter<F>(&self, F) where F: Fn(T);
1402+ fn len(&self) -> u32;
1403+ fn elt_at(&self, n: u32) -> T;
1404+ fn iter<F>(&self, F) where F: Fn(T);
14051405}
14061406```
14071407
@@ -1579,8 +1579,12 @@ impl Shape for Circle {
15791579 fn draw(&self, s: Surface) { do_draw_circle(s, *self); }
15801580 fn bounding_box(&self) -> BoundingBox {
15811581 let r = self.radius;
1582- BoundingBox{x: self.center.x - r, y: self.center.y - r,
1583- width: 2.0 * r, height: 2.0 * r}
1582+ BoundingBox {
1583+ x: self.center.x - r,
1584+ y: self.center.y - r,
1585+ width: 2.0 * r,
1586+ height: 2.0 * r,
1587+ }
15841588 }
15851589}
15861590```
@@ -1615,10 +1619,10 @@ are written after the `impl` keyword.
16151619```
16161620# trait Seq<T> { fn dummy(&self, _: T) { } }
16171621impl<T> Seq<T> for Vec<T> {
1618- /* ... */
1622+ /* ... */
16191623}
16201624impl Seq<bool> for u32 {
1621- /* Treat the integer as a sequence of bits */
1625+ /* Treat the integer as a sequence of bits */
16221626}
16231627```
16241628
@@ -1850,13 +1854,13 @@ An example of attributes:
18501854// A function marked as a unit test
18511855#[test]
18521856fn test_foo() {
1853- /* ... */
1857+ /* ... */
18541858}
18551859
18561860// A conditionally-compiled module
18571861#[cfg(target_os="linux")]
18581862mod bar {
1859- /* ... */
1863+ /* ... */
18601864}
18611865
18621866// A lint attribute used to suppress a warning/error
@@ -2899,9 +2903,9 @@ An example of an `as` expression:
28992903# fn len(values: &[f64]) -> i32 { 0 }
29002904
29012905fn average(values: &[f64]) -> f64 {
2902- let sum: f64 = sum(values);
2903- let size: f64 = len(values) as f64;
2904- sum / size
2906+ let sum: f64 = sum(values);
2907+ let size: f64 = len(values) as f64;
2908+ sum / size
29052909}
29062910```
29072911
@@ -3207,9 +3211,9 @@ may be specified with `...`. For example:
32073211# let x = 2;
32083212
32093213let message = match x {
3210- 0 | 1 => "not many",
3211- 2 ... 9 => "a few",
3212- _ => "lots"
3214+ 0 | 1 => "not many",
3215+ 2 ... 9 => "a few",
3216+ _ => "lots"
32133217};
32143218```
32153219
@@ -3228,9 +3232,9 @@ may refer to the variables bound within the pattern they follow.
32283232# fn process_other(i: i32) { }
32293233
32303234let message = match maybe_digit {
3231- Some(x) if x < 10 => process_digit(x),
3232- Some(x) => process_other(x),
3233- None => panic!()
3235+ Some(x) if x < 10 => process_digit(x),
3236+ Some(x) => process_other(x),
3237+ None => panic!()
32343238};
32353239```
32363240
@@ -3274,10 +3278,10 @@ An example of a `return` expression:
32743278
32753279```
32763280fn max(a: i32, b: i32) -> i32 {
3277- if a > b {
3278- return a;
3279- }
3280- return b;
3281+ if a > b {
3282+ return a;
3283+ }
3284+ return b;
32813285}
32823286```
32833287
@@ -3521,7 +3525,7 @@ An example of a `fn` type:
35213525
35223526```
35233527fn add(x: i32, y: i32) -> i32 {
3524- return x + y;
3528+ return x + y;
35253529}
35263530
35273531let mut x = add(5,7);
@@ -3601,19 +3605,19 @@ An example of a trait object:
36013605
36023606```
36033607trait Printable {
3604- fn stringify(&self) -> String;
3608+ fn stringify(&self) -> String;
36053609}
36063610
36073611impl Printable for i32 {
3608- fn stringify(&self) -> String { self.to_string() }
3612+ fn stringify(&self) -> String { self.to_string() }
36093613}
36103614
36113615fn print(a: Box<Printable>) {
3612- println!("{}", a.stringify());
3616+ println!("{}", a.stringify());
36133617}
36143618
36153619fn main() {
3616- print(Box::new(10) as Box<Printable>);
3620+ print(Box::new(10) as Box<Printable>);
36173621}
36183622```
36193623
@@ -3628,7 +3632,7 @@ its type parameters are types:
36283632``` ignore
36293633fn to_vec<A: Clone>(xs: &[A]) -> Vec<A> {
36303634 if xs.is_empty() {
3631- return vec![];
3635+ return vec![];
36323636 }
36333637 let first: A = xs[0].clone();
36343638 let mut rest: Vec<A> = to_vec(&xs[1..]);
@@ -3648,7 +3652,7 @@ it is an alias for the implementing type. For example, in:
36483652
36493653```
36503654trait Printable {
3651- fn make_string(&self) -> String;
3655+ fn make_string(&self) -> String;
36523656}
36533657
36543658impl Printable for String {
@@ -3716,7 +3720,7 @@ sites are:
37163720 fn bar (_ : i8 ) { }
37173721
37183722 fn main () {
3719- bar (128 );
3723+ bar (128 );
37203724 }
37213725 ```
37223726
0 commit comments