Skip to content

Commit 8a5e91a

Browse files
committed
don't use unstable rustfmt features
1 parent 6a5d3d3 commit 8a5e91a

File tree

7 files changed

+102
-100
lines changed

7 files changed

+102
-100
lines changed

examples/triangle/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern fn boot() {
1010
ff::Point { x: 40, y: 40 },
1111
ff::Point { x: 80, y: 40 },
1212
ff::Style {
13-
fill_color: ff::Color::LightGray,
13+
fill_color: ff::Color::LightGray,
1414
stroke_color: ff::Color::DarkBlue,
1515
stroke_width: 1,
1616
},

rustfmt.toml

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
imports_granularity = "Module"
2-
group_imports = "One"
3-
hex_literal_case = "Lower"
42
newline_style = "Unix"
5-
normalize_comments = true
6-
normalize_doc_attributes = true
7-
reorder_impl_items = true
8-
struct_field_align_threshold = 20
93
use_field_init_shorthand = true
104
force_explicit_abi = false
5+
6+
## Uncomment when stabilized:
7+
# group_imports = "One"
8+
# hex_literal_case = "Lower"
9+
# normalize_comments = true
10+
# normalize_doc_attributes = true
11+
# reorder_impl_items = true
12+
# struct_field_align_threshold = 20

src/fs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ impl<'a> Image<'a> {
244244
pub fn sub(&self, p: Point, s: Size) -> SubImage<'a> {
245245
SubImage {
246246
point: p,
247-
size: s,
248-
raw: self.raw,
247+
size: s,
248+
raw: self.raw,
249249
}
250250
}
251251
}
252252

253253
/// A subregion of an image. Constructed using [`Image::sub`].
254254
pub struct SubImage<'a> {
255255
pub(crate) point: Point,
256-
pub(crate) size: Size,
257-
pub(crate) raw: &'a [u8],
256+
pub(crate) size: Size,
257+
pub(crate) raw: &'a [u8],
258258
}

src/graphics/size.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ pub const HEIGHT: i32 = 160;
1414
/// The width and height must be positive.
1515
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
1616
pub struct Size {
17-
pub width: i32,
17+
pub width: i32,
1818
pub height: i32,
1919
}
2020

2121
impl Size {
2222
/// The screen size.
2323
pub const MAX: Size = Size {
24-
width: WIDTH,
24+
width: WIDTH,
2525
height: HEIGHT,
2626
};
2727

2828
#[must_use]
2929
pub fn new<I: Into<i32>>(width: I, height: I) -> Self {
3030
Self {
31-
width: width.into(),
31+
width: width.into(),
3232
height: height.into(),
3333
}
3434
}
@@ -37,7 +37,7 @@ impl Size {
3737
#[must_use]
3838
pub fn abs(self) -> Self {
3939
Self {
40-
width: self.width.abs(),
40+
width: self.width.abs(),
4141
height: self.height.abs(),
4242
}
4343
}
@@ -46,7 +46,7 @@ impl Size {
4646
#[must_use]
4747
pub fn component_min(self, other: Self) -> Self {
4848
Self {
49-
width: self.width.min(other.width),
49+
width: self.width.min(other.width),
5050
height: self.height.min(other.height),
5151
}
5252
}
@@ -55,7 +55,7 @@ impl Size {
5555
#[must_use]
5656
pub fn component_max(self, other: Self) -> Self {
5757
Self {
58-
width: self.width.max(other.width),
58+
width: self.width.max(other.width),
5959
height: self.height.max(other.height),
6060
}
6161
}
@@ -66,7 +66,7 @@ impl Add for Size {
6666

6767
fn add(self, other: Size) -> Self {
6868
Size {
69-
width: self.width + other.width,
69+
width: self.width + other.width,
7070
height: self.height + other.height,
7171
}
7272
}
@@ -84,7 +84,7 @@ impl Sub for Size {
8484

8585
fn sub(self, other: Size) -> Self {
8686
Size {
87-
width: self.width - other.width,
87+
width: self.width - other.width,
8888
height: self.height - other.height,
8989
}
9090
}
@@ -95,7 +95,7 @@ impl Sub<Point> for Size {
9595

9696
fn sub(self, other: Point) -> Self {
9797
Size {
98-
width: self.width - other.x,
98+
width: self.width - other.x,
9999
height: self.height - other.y,
100100
}
101101
}
@@ -113,7 +113,7 @@ impl Mul<i32> for Size {
113113

114114
fn mul(self, rhs: i32) -> Self {
115115
Size {
116-
width: self.width * rhs,
116+
width: self.width * rhs,
117117
height: self.height * rhs,
118118
}
119119
}
@@ -131,7 +131,7 @@ impl Div<i32> for Size {
131131

132132
fn div(self, rhs: i32) -> Self {
133133
Size {
134-
width: self.width / rhs,
134+
width: self.width / rhs,
135135
height: self.height / rhs,
136136
}
137137
}
@@ -159,15 +159,15 @@ impl Index<usize> for Size {
159159
impl From<Point> for Size {
160160
fn from(value: Point) -> Self {
161161
Self {
162-
width: value.x,
162+
width: value.x,
163163
height: value.y,
164164
}
165165
}
166166
}
167167
impl From<(i32, i32)> for Size {
168168
fn from(other: (i32, i32)) -> Self {
169169
Size {
170-
width: other.0,
170+
width: other.0,
171171
height: other.1,
172172
}
173173
}
@@ -176,7 +176,7 @@ impl From<(i32, i32)> for Size {
176176
impl From<[i32; 2]> for Size {
177177
fn from(other: [i32; 2]) -> Self {
178178
Size {
179-
width: other[0],
179+
width: other[0],
180180
height: other[1],
181181
}
182182
}
@@ -185,7 +185,7 @@ impl From<[i32; 2]> for Size {
185185
impl From<&[i32; 2]> for Size {
186186
fn from(other: &[i32; 2]) -> Self {
187187
Size {
188-
width: other[0],
188+
width: other[0],
189189
height: other[1],
190190
}
191191
}
@@ -216,7 +216,7 @@ where
216216
{
217217
fn from(other: Vector2<N>) -> Self {
218218
Self {
219-
width: other[0].into(),
219+
width: other[0].into(),
220220
height: other[1].into(),
221221
}
222222
}
@@ -229,7 +229,7 @@ where
229229
{
230230
fn from(other: &Vector2<N>) -> Self {
231231
Self {
232-
width: other[0].into(),
232+
width: other[0].into(),
233233
height: other[1].into(),
234234
}
235235
}

src/graphics/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct Style {
2424
impl Default for Style {
2525
fn default() -> Self {
2626
Self {
27-
fill_color: Color::None,
27+
fill_color: Color::None,
2828
stroke_color: Color::None,
2929
stroke_width: 1,
3030
}

src/input.rs

+36-36
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ impl Pad {
2222
#[must_use]
2323
pub fn as_dpad(&self) -> DPad {
2424
DPad {
25-
left: self.x <= -DPAD_THRESHOLD,
25+
left: self.x <= -DPAD_THRESHOLD,
2626
right: self.x >= DPAD_THRESHOLD,
27-
down: self.y <= -DPAD_THRESHOLD,
28-
up: self.y >= DPAD_THRESHOLD,
27+
down: self.y <= -DPAD_THRESHOLD,
28+
up: self.y >= DPAD_THRESHOLD,
2929
}
3030
}
3131

@@ -69,7 +69,7 @@ impl From<Point> for Pad {
6969
impl From<Pad> for Size {
7070
fn from(value: Pad) -> Self {
7171
Self {
72-
width: value.x,
72+
width: value.x,
7373
height: value.y,
7474
}
7575
}
@@ -94,10 +94,10 @@ impl From<Size> for Pad {
9494
/// (like up and right) to be active at the same time if the player presses a diagonal.
9595
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
9696
pub struct DPad {
97-
pub left: bool,
97+
pub left: bool,
9898
pub right: bool,
99-
pub up: bool,
100-
pub down: bool,
99+
pub up: bool,
100+
pub down: bool,
101101
}
102102

103103
impl From<Pad> for DPad {
@@ -111,32 +111,32 @@ impl DPad {
111111
#[must_use]
112112
pub fn just_pressed(&self, old: &Self) -> Self {
113113
Self {
114-
left: self.left && !old.left,
114+
left: self.left && !old.left,
115115
right: self.right && !old.right,
116-
up: self.up && !old.up,
117-
down: self.down && !old.down,
116+
up: self.up && !old.up,
117+
down: self.down && !old.down,
118118
}
119119
}
120120

121121
/// Given the old state, get directions that were pressed but aren't pressed now.
122122
#[must_use]
123123
pub fn just_released(&self, old: &Self) -> Self {
124124
Self {
125-
left: !self.left && old.left,
125+
left: !self.left && old.left,
126126
right: !self.right && old.right,
127-
up: !self.up && old.up,
128-
down: !self.down && old.down,
127+
up: !self.up && old.up,
128+
down: !self.down && old.down,
129129
}
130130
}
131131

132132
/// Given the old state, get directions that were pressed and are still pressed now.
133133
#[must_use]
134134
pub fn held(&self, old: &Self) -> Self {
135135
Self {
136-
left: self.left && old.left,
136+
left: self.left && old.left,
137137
right: self.right && old.right,
138-
up: self.up && old.up,
139-
down: self.down && old.down,
138+
up: self.up && old.up,
139+
down: self.down && old.down,
140140
}
141141
}
142142
}
@@ -145,13 +145,13 @@ impl DPad {
145145
#[derive(Default)]
146146
pub struct Buttons {
147147
/// If `a` button is pressed.
148-
pub a: bool,
148+
pub a: bool,
149149
/// If `b` button is pressed.
150-
pub b: bool,
150+
pub b: bool,
151151
/// If `x` button is pressed.
152-
pub x: bool,
152+
pub x: bool,
153153
/// If `y` button is pressed.
154-
pub y: bool,
154+
pub y: bool,
155155
/// If `menu` button is pressed.
156156
///
157157
/// For singleplayer games, the button press is always intercepted by the runtime.
@@ -169,10 +169,10 @@ impl Buttons {
169169
#[must_use]
170170
pub fn just_pressed(&self, old: &Self) -> Self {
171171
Self {
172-
a: self.a && !old.a,
173-
b: self.b && !old.b,
174-
x: self.x && !old.x,
175-
y: self.y && !old.y,
172+
a: self.a && !old.a,
173+
b: self.b && !old.b,
174+
x: self.x && !old.x,
175+
y: self.y && !old.y,
176176
menu: self.menu && !old.menu,
177177
}
178178
}
@@ -181,10 +181,10 @@ impl Buttons {
181181
#[must_use]
182182
pub fn just_released(&self, old: &Self) -> Self {
183183
Self {
184-
a: !self.a && old.a,
185-
b: !self.b && old.b,
186-
x: !self.x && old.x,
187-
y: !self.y && old.y,
184+
a: !self.a && old.a,
185+
b: !self.b && old.b,
186+
x: !self.x && old.x,
187+
y: !self.y && old.y,
188188
menu: !self.menu && old.menu,
189189
}
190190
}
@@ -193,10 +193,10 @@ impl Buttons {
193193
#[must_use]
194194
pub fn held(&self, old: &Self) -> Self {
195195
Self {
196-
a: self.a && old.a,
197-
b: self.b && old.b,
198-
x: self.x && old.x,
199-
y: self.y && old.y,
196+
a: self.a && old.a,
197+
b: self.b && old.b,
198+
x: self.x && old.x,
199+
y: self.y && old.y,
200200
menu: self.menu && old.menu,
201201
}
202202
}
@@ -225,10 +225,10 @@ pub fn read_pad(player: Player) -> Option<Pad> {
225225
pub fn read_buttons(player: Player) -> Buttons {
226226
let raw = unsafe { b::read_buttons(player.into()) };
227227
Buttons {
228-
a: has_bit_set(raw, 0),
229-
b: has_bit_set(raw, 1),
230-
x: has_bit_set(raw, 2),
231-
y: has_bit_set(raw, 3),
228+
a: has_bit_set(raw, 0),
229+
b: has_bit_set(raw, 1),
230+
x: has_bit_set(raw, 2),
231+
y: has_bit_set(raw, 3),
232232
menu: has_bit_set(raw, 4),
233233
}
234234
}

0 commit comments

Comments
 (0)