Skip to content

Commit e3c677d

Browse files
committed
chore: format using GA_HAT rules
1 parent 75a1b3c commit e3c677d

File tree

1 file changed

+78
-36
lines changed

1 file changed

+78
-36
lines changed

src/main.rs

Lines changed: 78 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ macro_rules! ipsum {
5151

5252
// ----------------------------------------------------------------------------
5353
lorem!(
54-
const _: u8 = 0;
54+
const _: u8 = 0;
5555
);
5656
ipsum!(
5757
const _: u8 = 0;
@@ -78,7 +78,11 @@ pub struct FieldAlign {
7878
}
7979

8080
#[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+
}
8286

8387
#[derive(Default, Debug, Serialize, Deserialize)]
8488
pub struct Bar {
@@ -88,23 +92,21 @@ pub struct Bar {
8892
}
8993

9094
// ----------------------------------------------------------------------------
91-
pub fn generic_compressed<Ipsum: Display+Debug=usize>() {}
95+
pub fn generic_compressed<Ipsum: Display + Debug = usize>() {}
9296
pub fn generic_wide<Ipsum: Display + Debug = usize>() {}
9397

9498
pub trait LoremTrait<T> {}
9599

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 {}
101101

102102
impl<T> LoremTrait<T> for std::collections::VecDeque<T> where Option<T>: Clone {}
103103

104104
struct DummyIter;
105105
impl Iterator for DummyIter {
106106
const SIZE: usize = 0123456789;
107-
fn next(&mut self) -> Option<Self::Item> { None }
107+
fn next(&mut self) -> Option<Self::Item> {
108+
None
109+
}
108110
type Item = i32;
109111
}
110112

@@ -122,7 +124,9 @@ impl Iterator for DummyIter {
122124
/// );
123125
/// # fn add_one(x: i32) -> i32 { x + 1 }
124126
/// ```
125-
pub fn add_one(x: i32) -> i32 { x + 1 }
127+
pub fn add_one(x: i32) -> i32 {
128+
x + 1
129+
}
126130

127131
// ----------------------------------------------------------------------------
128132
/* This is a block comment that rustfmt can optionally convert into a line
@@ -144,17 +148,29 @@ fn ranges_demo() {
144148
}
145149

146150
// ----------------------------------------------------------------------------
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+
];
148158

149159
// ----------------------------------------------------------------------------
150160
const LONG_STR: &str = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet consectetur adipiscing";
151161

152162
// ----------------------------------------------------------------------------
153163
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;
155167
let a = Foo { x, y, z }; // shorthand
156168
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+
}
158174
}
159175

160176
// ----------------------------------------------------------------------------
@@ -168,11 +184,16 @@ fn overflow_demo() {
168184
param
169185
});
170186

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+
);
172195

173-
foo(ctx, &[
174-
1, 2, 3, 4, 5,
175-
]);
196+
foo(ctx, &[1, 2, 3, 4, 5]);
176197

177198
foo(ctx, vec![1, 2, 3, 4, 5]);
178199
}
@@ -185,7 +206,7 @@ fn match_and_closure_demo(x: i32) {
185206
});
186207

187208
match x {
188-
| 0 | 1 => println!("small"),
209+
0 | 1 => println!("small"),
189210
2 => {
190211
println!("two");
191212
}
@@ -195,18 +216,28 @@ fn match_and_closure_demo(x: i32) {
195216
}
196217

197218
// ----------------------------------------------------------------------------
198-
fn single_line_things() -> i32 { 42 }
219+
fn single_line_things() -> i32 {
220+
42
221+
}
199222

200223
fn let_else_demo() {
201224
let opt = Some(10);
202225
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+
}
204231
}
205232

206-
fn return_semicolon() -> i32 { return 0; }
233+
fn return_semicolon() -> i32 {
234+
return 0;
235+
}
207236

208237
// ----------------------------------------------------------------------------
209-
fn nested_parens() { (((((println!("nested")))))); }
238+
fn nested_parens() {
239+
(println!("nested"));
240+
}
210241

211242
// ----------------------------------------------------------------------------
212243
fn try_demo() -> Result<(), io::Error> {
@@ -223,32 +254,32 @@ fn try_demo() -> Result<(), io::Error> {
223254
pub struct DocAttrItem;
224255

225256
// ----------------------------------------------------------------------------
226-
#[cfg(any())] use std::marker::PhantomData;
257+
#[cfg(any())]
258+
use std::marker::PhantomData;
227259

228260
// ----------------------------------------------------------------------------
229261
#[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+
}
238265

239266
fn destructuring() {
240267
let Foo { x, y, z } = Foo { x: 1, y: 2, z: 3 };
241268
}
242269

243270
// ----------------------------------------------------------------------------
244271
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+
};
246277
}
247278

248279
// ----------------------------------------------------------------------------
249280
mod reorder_demo {
250-
use std::time::{Duration, SystemTime};
251281
use std::cmp::{Ordering, Reverse};
282+
use std::time::{Duration, SystemTime};
252283
use std::{mem, ptr};
253284
}
254285

@@ -267,10 +298,18 @@ fn main() {
267298
let _hex_sum = HEXES.iter().sum::<u64>();
268299

269300
// ----------------------------------------------------------
270-
let _bar = Bar { ipsum: 10, dolor: 20, sit: 30 };
301+
let _bar = Bar {
302+
ipsum: 10,
303+
dolor: 20,
304+
sit: 30,
305+
};
271306

272307
// ----------------------------------------------------------
273-
let _fa = FieldAlign { x: 1, yy: 2, zzz: 3 };
308+
let _fa = FieldAlign {
309+
x: 1,
310+
yy: 2,
311+
zzz: 3,
312+
};
274313

275314
// ----------------------------------------------------------
276315
nested_parens();
@@ -279,5 +318,8 @@ fn main() {
279318
let _arr = [1, 2, 3, 1234567890];
280319

281320
// ----------------------------------------------------------
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<_>>();
283325
}

0 commit comments

Comments
 (0)