@@ -51,7 +51,7 @@ macro_rules! ipsum {
51
51
52
52
// ----------------------------------------------------------------------------
53
53
lorem ! (
54
- const _: u8 = 0 ;
54
+ const _: u8 = 0 ;
55
55
) ;
56
56
ipsum ! (
57
57
const _: u8 = 0 ;
@@ -78,7 +78,11 @@ pub struct FieldAlign {
78
78
}
79
79
80
80
#[ derive( Default , Debug , Serialize , Deserialize ) ]
81
- pub struct Foo { x : i32 , y : i32 , z : i32 }
81
+ pub struct Foo {
82
+ x : i32 ,
83
+ y : i32 ,
84
+ z : i32 ,
85
+ }
82
86
83
87
#[ derive( Default , Debug , Serialize , Deserialize ) ]
84
88
pub struct Bar {
@@ -88,23 +92,21 @@ pub struct Bar {
88
92
}
89
93
90
94
// ----------------------------------------------------------------------------
91
- pub fn generic_compressed < Ipsum : Display + Debug = usize > ( ) { }
95
+ pub fn generic_compressed < Ipsum : Display + Debug = usize > ( ) { }
92
96
pub fn generic_wide < Ipsum : Display + Debug = usize > ( ) { }
93
97
94
98
pub trait LoremTrait < T > { }
95
99
96
- impl < T > LoremTrait < T > for Vec < T >
97
- where
98
- Option < T > : Clone ,
99
- {
100
- }
100
+ impl < T > LoremTrait < T > for Vec < T > where Option < T > : Clone { }
101
101
102
102
impl < T > LoremTrait < T > for std:: collections:: VecDeque < T > where Option < T > : Clone { }
103
103
104
104
struct DummyIter ;
105
105
impl Iterator for DummyIter {
106
106
const SIZE : usize = 0123456789 ;
107
- fn next ( & mut self ) -> Option < Self :: Item > { None }
107
+ fn next ( & mut self ) -> Option < Self :: Item > {
108
+ None
109
+ }
108
110
type Item = i32 ;
109
111
}
110
112
@@ -122,7 +124,9 @@ impl Iterator for DummyIter {
122
124
/// );
123
125
/// # fn add_one(x: i32) -> i32 { x + 1 }
124
126
/// ```
125
- pub fn add_one ( x : i32 ) -> i32 { x + 1 }
127
+ pub fn add_one ( x : i32 ) -> i32 {
128
+ x + 1
129
+ }
126
130
127
131
// ----------------------------------------------------------------------------
128
132
/* This is a block comment that rustfmt can optionally convert into a line
@@ -144,17 +148,29 @@ fn ranges_demo() {
144
148
}
145
149
146
150
// ----------------------------------------------------------------------------
147
- const HEXES : [ u64 ; 5 ] = [ 0x0000_0000_0000_0000 , 0xAAAA_AAAA_AAAA_AAAA , 0xbbbb_bbbb_bbbb_bbbb , 0xCCCC_CCCC_CCCC_CCCC , 0xDDDD_DDDD_DDDD_DDDD ] ;
151
+ const HEXES : [ u64 ; 5 ] = [
152
+ 0x0000_0000_0000_0000 ,
153
+ 0xAAAA_AAAA_AAAA_AAAA ,
154
+ 0xbbbb_bbbb_bbbb_bbbb ,
155
+ 0xCCCC_CCCC_CCCC_CCCC ,
156
+ 0xDDDD_DDDD_DDDD_DDDD ,
157
+ ] ;
148
158
149
159
// ----------------------------------------------------------------------------
150
160
const LONG_STR : & str = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet consectetur adipiscing" ;
151
161
152
162
// ----------------------------------------------------------------------------
153
163
fn make_foo ( ) -> Foo {
154
- let x = 1 ; let y = 2 ; let z = 3 ;
164
+ let x = 1 ;
165
+ let y = 2 ;
166
+ let z = 3 ;
155
167
let a = Foo { x, y, z } ; // shorthand
156
168
let b = Foo { x : x, y : y, z : z } ; // no shorthand
157
- if x > 0 { a } else { b }
169
+ if x > 0 {
170
+ a
171
+ } else {
172
+ b
173
+ }
158
174
}
159
175
160
176
// ----------------------------------------------------------------------------
@@ -168,11 +184,16 @@ fn overflow_demo() {
168
184
param
169
185
} ) ;
170
186
171
- foo ( ctx, Bar { ipsum : 1 , dolor : 2 , sit : 3 } ) ;
187
+ foo (
188
+ ctx,
189
+ Bar {
190
+ ipsum : 1 ,
191
+ dolor : 2 ,
192
+ sit : 3 ,
193
+ } ,
194
+ ) ;
172
195
173
- foo ( ctx, & [
174
- 1 , 2 , 3 , 4 , 5 ,
175
- ] ) ;
196
+ foo ( ctx, & [ 1 , 2 , 3 , 4 , 5 ] ) ;
176
197
177
198
foo ( ctx, vec ! [ 1 , 2 , 3 , 4 , 5 ] ) ;
178
199
}
@@ -185,7 +206,7 @@ fn match_and_closure_demo(x: i32) {
185
206
} ) ;
186
207
187
208
match x {
188
- | 0 | 1 => println ! ( "small" ) ,
209
+ 0 | 1 => println ! ( "small" ) ,
189
210
2 => {
190
211
println ! ( "two" ) ;
191
212
}
@@ -195,18 +216,28 @@ fn match_and_closure_demo(x: i32) {
195
216
}
196
217
197
218
// ----------------------------------------------------------------------------
198
- fn single_line_things ( ) -> i32 { 42 }
219
+ fn single_line_things ( ) -> i32 {
220
+ 42
221
+ }
199
222
200
223
fn let_else_demo ( ) {
201
224
let opt = Some ( 10 ) ;
202
225
let Some ( v) = opt else { return } ;
203
- if v > 5 { println ! ( "gt5" ) } else { println ! ( "le5" ) }
226
+ if v > 5 {
227
+ println ! ( "gt5" )
228
+ } else {
229
+ println ! ( "le5" )
230
+ }
204
231
}
205
232
206
- fn return_semicolon ( ) -> i32 { return 0 ; }
233
+ fn return_semicolon ( ) -> i32 {
234
+ return 0 ;
235
+ }
207
236
208
237
// ----------------------------------------------------------------------------
209
- fn nested_parens ( ) { ( ( ( ( ( println ! ( "nested" ) ) ) ) ) ) ; }
238
+ fn nested_parens ( ) {
239
+ ( println ! ( "nested" ) ) ;
240
+ }
210
241
211
242
// ----------------------------------------------------------------------------
212
243
fn try_demo ( ) -> Result < ( ) , io:: Error > {
@@ -223,32 +254,32 @@ fn try_demo() -> Result<(), io::Error> {
223
254
pub struct DocAttrItem ;
224
255
225
256
// ----------------------------------------------------------------------------
226
- #[ cfg( any( ) ) ] use std:: marker:: PhantomData ;
257
+ #[ cfg( any( ) ) ]
258
+ use std:: marker:: PhantomData ;
227
259
228
260
// ----------------------------------------------------------------------------
229
261
#[ allow( clippy:: too_many_arguments) ]
230
- fn many_args (
231
- a : i32 ,
232
- b : i32 ,
233
- c : i32 ,
234
- d : i32 ,
235
- e : i32 ,
236
- f : i32 ,
237
- ) -> i32 { a + b + c + d + e + f }
262
+ fn many_args ( a : i32 , b : i32 , c : i32 , d : i32 , e : i32 , f : i32 ) -> i32 {
263
+ a + b + c + d + e + f
264
+ }
238
265
239
266
fn destructuring ( ) {
240
267
let Foo { x, y, z } = Foo { x : 1 , y : 2 , z : 3 } ;
241
268
}
242
269
243
270
// ----------------------------------------------------------------------------
244
271
fn spacing_demo < T : Eq > ( t : T ) {
245
- let _lorem: Bar = Bar { ipsum : 1 , dolor : 2 , sit : 3 } ;
272
+ let _lorem: Bar = Bar {
273
+ ipsum : 1 ,
274
+ dolor : 2 ,
275
+ sit : 3 ,
276
+ } ;
246
277
}
247
278
248
279
// ----------------------------------------------------------------------------
249
280
mod reorder_demo {
250
- use std:: time:: { Duration , SystemTime } ;
251
281
use std:: cmp:: { Ordering , Reverse } ;
282
+ use std:: time:: { Duration , SystemTime } ;
252
283
use std:: { mem, ptr} ;
253
284
}
254
285
@@ -267,10 +298,18 @@ fn main() {
267
298
let _hex_sum = HEXES . iter ( ) . sum :: < u64 > ( ) ;
268
299
269
300
// ----------------------------------------------------------
270
- let _bar = Bar { ipsum : 10 , dolor : 20 , sit : 30 } ;
301
+ let _bar = Bar {
302
+ ipsum : 10 ,
303
+ dolor : 20 ,
304
+ sit : 30 ,
305
+ } ;
271
306
272
307
// ----------------------------------------------------------
273
- let _fa = FieldAlign { x : 1 , yy : 2 , zzz : 3 } ;
308
+ let _fa = FieldAlign {
309
+ x : 1 ,
310
+ yy : 2 ,
311
+ zzz : 3 ,
312
+ } ;
274
313
275
314
// ----------------------------------------------------------
276
315
nested_parens ( ) ;
@@ -279,5 +318,8 @@ fn main() {
279
318
let _arr = [ 1 , 2 , 3 , 1234567890 ] ;
280
319
281
320
// ----------------------------------------------------------
282
- let _v = ( 0 ..10 ) . map ( |x| x + 1 ) . filter ( |x| x % 2 == 0 ) . collect :: < Vec < _ > > ( ) ;
321
+ let _v = ( 0 ..10 )
322
+ . map ( |x| x + 1 )
323
+ . filter ( |x| x % 2 == 0 )
324
+ . collect :: < Vec < _ > > ( ) ;
283
325
}
0 commit comments