Skip to content

Commit a5bf3ba

Browse files
authored
Make improvements to the CI (#54)
- Switch the default branch to "main" - Run `cargo fmt --check` during CI - Format the source code - Improve job names
1 parent f9e0504 commit a5bf3ba

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [main]
66
pull_request:
77
merge_group:
88
types: [checks_requested]
@@ -17,13 +17,13 @@ jobs:
1717
toolchain: stable
1818
override: true
1919
profile: minimal
20+
- name: Check Formatting
21+
run: cargo fmt --check
2022
- name: Test
2123
run: cargo test
22-
23-
- name: Serde check
24+
- name: Check (`--features="serde_serialization"`)
2425
run: cargo check --features="serde_serialization"
25-
26-
- name: Num traits check
26+
- name: Check (`--features="num_traits"`)
2727
run: cargo check --features="num_traits"
2828

2929
build_result:

src/app_unit.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55
#[cfg(feature = "num_traits")]
66
use num_traits::Zero;
77
#[cfg(feature = "serde_serialization")]
8-
use serde::{Serialize, Deserialize, Deserializer};
8+
use serde::{Deserialize, Deserializer, Serialize};
99

10-
use std::{fmt, i32, default::Default, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign}};
1110
use std::iter::Sum;
11+
use std::{
12+
default::Default,
13+
fmt, i32,
14+
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign},
15+
};
1216

1317
/// The number of app units in a pixel.
1418
pub const AU_PER_PX: i32 = 60;
1519
/// The minimum number of app units, same as in Gecko.
16-
pub const MIN_AU: Au = Au(- ((1 << 30) - 1));
20+
pub const MIN_AU: Au = Au(-((1 << 30) - 1));
1721
/// The maximum number of app units, same as in Gecko.
18-
///
22+
///
1923
/// (1 << 30) - 1 lets us add/subtract two Au and check for overflow after the operation.
2024
pub const MAX_AU: Au = Au((1 << 30) - 1);
2125

22-
2326
#[repr(transparent)]
2427
#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Eq, Ord, Default)]
2528
#[cfg_attr(feature = "serde_serialization", derive(Serialize), serde(transparent))]
@@ -73,7 +76,6 @@ impl Sub for Au {
7376
fn sub(self, other: Au) -> Au {
7477
Au(self.0 - other.0).clamp()
7578
}
76-
7779
}
7880

7981
impl Mul<Au> for i32 {
@@ -391,7 +393,7 @@ fn convert() {
391393
assert_eq!(Au::from_f64_px(6.13), Au(368));
392394
}
393395

394-
#[cfg(feature ="serde_serialization")]
396+
#[cfg(feature = "serde_serialization")]
395397
#[test]
396398
fn serialize() {
397399
let serialized = ron::to_string(&Au(42)).unwrap();

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
99
mod app_unit;
1010

11-
pub use app_unit::{Au, MIN_AU, MAX_AU, AU_PER_PX};
11+
pub use app_unit::{Au, AU_PER_PX, MAX_AU, MIN_AU};

0 commit comments

Comments
 (0)